ZQuest Classic Coverage Report


Directory: src/
File: src/zq/zquest.cpp
Date: 2025-08-04 03:39:32
Exec Total Coverage
Lines: 2261 14834 15.2%
Functions: 49 740 6.6%
Branches: 1400 11049 12.7%

Line Branch Exec Source
1 #include "allegro/gui.h"
2 #include "base/files.h"
3 #include "base/mapscr.h"
4 #include "dialog/edit_region.h"
5
6 #include <memory>
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <cstring>
10 #include <sstream>
11 #include <ctype.h>
12 #include <assert.h>
13 #include <time.h>
14 #include <vector>
15 #include <filesystem>
16 #include <base/new_menu.h>
17
18 #include "dialog/info_lister.h"
19 #ifdef __APPLE__
20 // malloc.h is deprecated, but malloc also lives in stdlib
21 #include <stdlib.h>
22 #else
23 #include <malloc.h>
24 #endif
25
26 #include "zalleg/zalleg.h"
27 #include "base/qrs.h"
28 #include "base/dmap.h"
29 #include "base/msgstr.h"
30 #include "base/packfile.h"
31 #include "base/cpool.h"
32 #include "base/autocombo.h"
33 #include "base/render.h"
34 #include "base/version.h"
35 #include "zq/autocombo/autopattern_base.h"
36 #include "zq/autocombo/pattern_basic.h"
37 #include "zq/autocombo/pattern_flatmtn.h"
38 #include "zq/autocombo/pattern_fence.h"
39 #include "zq/autocombo/pattern_cakemtn.h"
40 #include "zq/autocombo/pattern_relational.h"
41 #include "zq/autocombo/pattern_dungeoncarve.h"
42 #include "zq/autocombo/pattern_dormtn.h"
43 #include "zq/autocombo/pattern_tiling.h"
44 #include "zq/autocombo/pattern_replace.h"
45 #include "zq/autocombo/pattern_denseforest.h"
46 #include "zq/autocombo/pattern_extend.h"
47 #include "zq/render_hotkeys.h"
48 #include "zq/render_minimap.h"
49 #include "zq/render_tooltip.h"
50 #include "base/misctypes.h"
51 #include "parser/Compiler.h"
52 #include "base/zc_alleg.h"
53 #include "particles.h"
54 #include "dialog/combopool.h"
55 #include "dialog/alert.h"
56 #include "dialog/alertfunc.h"
57 #include "zq/gui/edit_autocombo.h"
58
59 #include <al5_img.h>
60 #include <loadpng.h>
61 #include <fmt/format.h>
62
63 #include "dialog/cheat_codes.h"
64 #include "dialog/set_password.h"
65 #include "dialog/foodlg.h"
66 #include "dialog/quest_rules.h"
67 #include "dialog/script_rules.h"
68 #include "dialog/headerdlg.h"
69 #include "dialog/ffc_editor.h"
70 #include "dialog/screen_data.h"
71 #include "dialog/edit_dmap.h"
72 #include "dialog/compilezscript.h"
73 #include "dialog/screen_enemies.h"
74 #include "dialog/enemypattern.h"
75 #include "dialog/sfxdata.h"
76 #include "dialog/mapstyles.h"
77 #include "dialog/externs.h"
78
79 #include "base/gui.h"
80 #include "gui/jwin_a5.h"
81 #include "gui/jwin.h"
82 #include "zc_list_data.h"
83 #include "gui/editbox.h"
84 #include "zq/zq_misc.h"
85 #include "zq/zq_tiles.h" // tile and combo code
86
87 #include "zq/zquest.h"
88 #include "zq/ffasm.h"
89 #include "zq/render.h"
90
91 // the following are used by both zelda.cc and zquest.cc
92 #include "base/zdefs.h"
93 #include "base/qrs.h"
94 #include "tiles.h"
95 #include "base/colors.h"
96 #include "base/qst.h"
97 #include "base/zsys.h"
98 #include "base/zapp.h"
99 #include "base/process_management.h"
100 #include "play_midi.h"
101 #include "sound/zcmusic.h"
102
103 #include "midi.h"
104 #include "sprite.h"
105 #include "fontsdat.h"
106 #include "base/jwinfsel.h"
107 #include "zq/zq_class.h"
108 #include "subscr.h"
109 #include "zq/zq_subscr.h"
110 #include "zc/ffscript.h"
111 #include "gui/EditboxNew.h"
112 #include "sfx.h"
113 #include "zq/zq_custom.h" // custom items and guys
114 #include "zq/zq_strings.h"
115 #include "zq/questReport.h"
116 #include <fstream>
117 #include "drawing.h"
118 #include "zconsole/ConsoleLogger.h"
119 #include "colorname.h"
120 #include "zq/zq_hotkey.h"
121 #include "zq/package.h"
122 #include "zq/zq_files.h"
123 #include "music_playback.h"
124
125 //Windows mmemory tools
126 #ifdef _WIN32
127 #include <windows.h>
128 #include <stdio.h>
129 #include <psapi.h>
130 #pragma comment(lib, "psapi.lib") // Needed to avoid linker issues. -Z
131 #endif
132
133 #ifdef __EMSCRIPTEN__
134 #include <emscripten/emscripten.h>
135 #endif
136
137 #define MIDI_TRACK_BUFFER_SIZE 50
138 extern CConsoleLoggerEx parser_console;
139
140 using ZScript::disassembled_script_data;
141 void write_script(vector<shared_ptr<ZScript::Opcode>> const& zasm, string& dest,
142 bool commented, map<string,disassembled_script_data>* scr_meta_map);
143
144 namespace fs = std::filesystem;
145
146 #if defined(ALLEGRO_WINDOWS)
147 static const char *data_path_name = "win_data_path";
148 static const char *midi_path_name = "win_midi_path";
149 static const char *image_path_name = "win_image_path";
150 static const char *tmusic_path_name = "win_tmusic_path";
151 static const char *last_quest_name = "win_last_quest";
152 static const char *qtname_name = "win_qtname%d";
153 static const char *qtpath_name = "win_qtpath%d";
154 #elif defined(ALLEGRO_LINUX)
155 static const char *data_path_name = "linux_data_path";
156 static const char *midi_path_name = "linux_midi_path";
157 static const char *image_path_name = "linux_image_path";
158 static const char *tmusic_path_name = "linux_tmusic_path";
159 static const char *last_quest_name = "linux_last_quest";
160 static const char *qtname_name = "linux_qtname%d";
161 static const char *qtpath_name = "linux_qtpath%d";
162 #elif defined(__APPLE__)
163 static const char *data_path_name = "macosx_data_path";
164 static const char *midi_path_name = "macosx_midi_path";
165 static const char *image_path_name = "macosx_image_path";
166 static const char *tmusic_path_name = "macosx_tmusic_path";
167 static const char *last_quest_name = "macosx_last_quest";
168 static const char *qtname_name = "macosx_qtname%d";
169 static const char *qtpath_name = "macosx_qtpath%d";
170 #endif
171
172 #include "base/win32.h"
173
174 #include "zq/zq_init.h"
175 #include "zq/zq_doors.h"
176 #include "zq/zq_cset.h"
177 #include "zinfo.h"
178
179 #ifdef _MSC_VER
180 #include <crtdbg.h>
181
182 #endif
183
184 // MSVC fix
185 #if _MSC_VER >= 1900
186 FILE _iob[] = { *stdin, *stdout, *stderr };
187 extern "C" FILE * __cdecl __iob_func(void) { return _iob; }
188 #endif
189
190 extern byte monochrome_console;
191
192 #include "zconsole/ConsoleLogger.h"
193
194 extern CConsoleLoggerEx zscript_coloured_console;
195
196 uint8_t console_is_open = 0;
197 bool is_zq_replay_test = false;
198
199 #include "base/util.h"
200
201 #ifdef __EMSCRIPTEN__
202 #include "base/emscripten_utils.h"
203 #endif
204
205 using namespace util;
206
207 using std::vector;
208 using std::map;
209 using std::stringstream;
210
211 12 FFScript FFCore;
212
213 void load_size_poses();
214 void do_previewtext();
215 bool do_slots(vector<shared_ptr<ZScript::Opcode>> const& zasm,
216 map<string, disassembled_script_data> &scripts, int assign_mode);
217
218 int32_t startdmapxy[6] = {-1000, -1000, -1000, -1000, -1000, -1000};
219 bool cancelgetnum=false;
220
221 int32_t tooltip_timer=0, tooltip_maxtimer=30, tooltip_current_ffc=0;
222 int32_t combobrushoverride=-1;
223 ComboPosition mouse_combo_pos;
224
225 int32_t original_playing_field_offset=0;
226 12 int32_t playing_field_offset=original_playing_field_offset;
227 int32_t passive_subscreen_height=56;
228
229 bool disable_saving=false, OverwriteProtection;
230 bool halt=false;
231 bool show_sprites=true;
232 bool show_hitboxes = false;
233 bool zq_ignore_item_ownership = true;
234
235 // Used to find FFC script names
236 vector<string> asffcscripts;
237 vector<string> asglobalscripts;
238 vector<string> asitemscripts;
239 vector<string> asnpcscripts;
240 vector<string> aseweaponscripts;
241 vector<string> aslweaponscripts;
242 vector<string> asplayerscripts;
243 vector<string> asdmapscripts;
244 vector<string> asscreenscripts;
245 vector<string> asitemspritescripts;
246 vector<string> ascomboscripts;
247 vector<string> asgenericscripts;
248 vector<string> assubscreenscripts;
249
250 vector<string> ZQincludePaths;
251
252 int32_t CSET_SIZE = 16;
253 int32_t CSET_SHFT = 4;
254 //editbox_data temp_eb_data;
255 /*
256 #define CSET(x) ((x)<<CSET_SHFT)
257 #define csBOSS 14
258 */
259
260 /*
261 enum { m_block, m_coords, m_flags, m_guy, m_warp, m_misc, m_layers,
262 m_menucount };
263 */
264 void update_combo_cycling();
265 void update_freeform_combos();
266
267 /*
268 #define MAXMICE 14
269 #define MAXARROWS 8
270 #define SHADOW_DEPTH 2
271 */
272 int32_t coord_timer=0, coord_frame=0;
273 int32_t blackout_color, zq_screen_w, zq_screen_h;
274 int32_t draw_mode=0;
275
276 12 size_and_pos minimap;
277 12 size_and_pos real_minimap;
278
279 12 size_and_pos minimap_zoomed;
280 12 size_and_pos real_minimap_zoomed;
281
282 12 size_and_pos map_page_bar[9];
283 int32_t mappage_count = 9;
284
285 12 size_and_pos combolist[MAX_COMBO_COLS];
286 12 size_and_pos combolistscrollers[MAX_COMBO_COLS];
287 int32_t num_combo_cols = MAX_COMBO_COLS;
288
289 static bool zoom_in_btn_disabled;
290 static bool zoom_out_btn_disabled;
291 12 size_and_pos zoominbtn;
292 12 size_and_pos zoomoutbtn;
293 12 size_and_pos compactbtn;
294 12 size_and_pos mainbar;
295
296 12 size_and_pos screrrorpos;
297
298 12 size_and_pos comboaliaslist[MAX_COMBO_COLS];
299 12 size_and_pos comboalias_preview;
300 12 size_and_pos combopool_preview;
301 12 size_and_pos combopool_prevbtn;
302
303 12 size_and_pos combo_merge_btn;
304
305 12 size_and_pos combo_preview;
306 12 size_and_pos combo_preview2;
307 12 size_and_pos combo_preview_text1;
308 12 size_and_pos combo_preview_text2;
309 12 size_and_pos combolist_window;
310 12 size_and_pos drawmode_btn;
311 12 size_and_pos main_panel;
312 12 size_and_pos squares_panel;
313 12 size_and_pos preview_panel;
314 12 size_and_pos layer_panel;
315 12 size_and_pos preview_text;
316
317 12 size_and_pos favorites_window;
318 12 size_and_pos favorites_list;
319 12 size_and_pos favorites_x;
320 12 size_and_pos favorites_infobtn;
321 12 size_and_pos favorites_zoombtn;
322 12 size_and_pos favorites_pgleft;
323 12 size_and_pos favorites_pgright;
324
325 12 size_and_pos commands_window;
326 12 size_and_pos commands_list;
327 12 size_and_pos commands_x;
328 12 size_and_pos commands_infobtn;
329 12 size_and_pos commands_zoombtn;
330 12 size_and_pos commands_txt;
331
332 12 size_and_pos squarepanel_swap_btn;
333 12 size_and_pos squarepanel_up_btn;
334 12 size_and_pos squarepanel_down_btn;
335 12 size_and_pos itemsqr_pos;
336 12 size_and_pos flagsqr_pos;
337 12 size_and_pos stairsqr_pos;
338 12 size_and_pos warparrival_pos;
339 12 size_and_pos warpret_pos[4];
340 12 size_and_pos enemy_prev_pos;
341
342 12 size_and_pos txtoffs_single;
343 12 size_and_pos txtoffs_double_1;
344 12 size_and_pos txtoffs_double_2;
345 int32_t panel_align = 1;
346
347 int32_t command_buttonwidth = 88;
348 int32_t command_buttonheight = 19;
349
350 int32_t layerpanel_buttonwidth = 58;
351 int32_t layerpanel_buttonheight = 16;
352
353 int32_t layerpanel_checkbox_hei = 13;
354 int32_t layerpanel_checkbox_wid = 13;
355
356 int32_t favorite_combos[MAXFAVORITECOMBOS];
357 byte favorite_combo_modes[MAXFAVORITECOMBOS];
358 bool ShowFavoriteComboModes;
359 byte FavoriteComboPage;
360
361 char comboprev_buf[512] = {0};
362 char comboprev_buf2[512] = {0};
363 FONT* txfont;
364
365 const char *roomtype_string[MAXROOMTYPES] =
366 {
367 "(None)","Special Item","Pay for Info","Secret Money","Gamble",
368 "Door Repair","Red Potion or Heart Container","Feed the Goriya","Triforce Check",
369 "Potion Shop","Shop","More Bombs","Leave Money or Life","10 Rupees",
370 "3-Stair Warp","Ganon","Zelda", "-<item pond>", "1/2 Magic Upgrade", "Learn Slash", "More Arrows","Take One Item"
371 };
372
373 const char *catchall_string[MAXROOMTYPES] =
374 {
375 "Generic Catchall","Special Item","Info Type","Amount","Generic Catchall","Repair Fee","Generic Catchall","Generic Catchall","Generic Catchall","Shop Type",
376 "Shop Type","Price","Price","Generic Catchall","Warp Ring","Generic Catchall","Generic Catchall", "Generic Catchall", "Generic Catchall",
377 "Generic Catchall", "Price","Shop Type","Bottle Shop Type"
378 };
379
380 #define MAXPOOLCOMBOS MAXFAVORITECOMBOS
381
382 struct cmbdat_pair
383 {
384 int32_t data;
385 byte cset;
386 15120 cmbdat_pair() { clear(); }
387 25200 void clear()
388 {
389 25200 data = -1;
390 25200 cset = 0;
391 25200 }
392 bool valid() const
393 {
394 return data > -1;
395 }
396 };
397 bool pool_dirty=true;
398 12 cmbdat_pair pool_combos[MAXPOOLCOMBOS];
399 static std::vector<byte> pool;
400
401 bool pool_valid()
402 {
403 if(pool_dirty)
404 {
405 pool.clear();
406 for(auto q = 0; q < MAXPOOLCOMBOS; ++q)
407 {
408 if(pool_combos[q].valid())
409 pool.push_back(q);
410 }
411 pool_dirty = false;
412 }
413 return pool.size() > 0;
414 }
415 cmbdat_pair const& get_pool_combo()
416 {
417 if(!pool_valid()) return pool_combos[0];
418 auto ind = zc_rand(pool.size()-1);
419 return pool_combos[pool.at(ind)];
420 }
421
422 int32_t mouse_scroll_h;
423
424 // 'mapscreen' refers to the area of the editor where the screen is drawn.
425 int32_t mapscreen_x, mapscreen_y, showedges, showallpanels;
426 // The scale of the entire mapscreen area. This varies based on compact/extended mode.
427 static int mapscreen_screenunit_scale;
428 // The scale of an individual screen being drawn. This is `mapscreen_screenunit_scale / Map.getViewSize()`.
429 static double mapscreen_single_scale;
430 // 4 is roughly the largest value where things render okay. Beyond that, our low bitmap resolution results in tons
431 // of downsampling. Let users go to 16 anyway.
432 static int mapscreen_num_screens_to_draw_max = 16;
433 // The valid layers for the current screen(s).
434 static bool mapscreen_valid_layers[6];
435
436 struct VisibleScreen
437 {
438 int dx, dy;
439 int xoff, yoff;
440 mapscr* scr;
441 int screen;
442 };
443 static std::vector<VisibleScreen> visible_screens;
444 static VisibleScreen* active_visible_screen = nullptr;
445
446 static void set_active_visible_screen(mapscr* scr)
447 {
448 active_visible_screen = nullptr;
449 for (auto& visible_screen : visible_screens)
450 {
451 if (visible_screen.scr == scr)
452 {
453 active_visible_screen = &visible_screen;
454 break;
455 }
456 }
457 }
458
459 static ComboPosition get_mapscreen_mouse_combo_pos()
460 {
461 int startxint = mapscreen_x+(showedges?int(16*mapscreen_single_scale):0);
462 int startyint = mapscreen_y+(showedges?int(16*mapscreen_single_scale):0);
463 int cx = (gui_mouse_x()-startxint)/(16*mapscreen_single_scale);
464 int cy = (gui_mouse_y()-startyint)/(16*mapscreen_single_scale);
465 return ComboPosition{cx, cy};
466 }
467
468 static void refresh_visible_screens()
469 {
470 int num_screens = Map.getViewSize();
471 int screen_width = mapscreenbmp->w * mapscreen_single_scale;
472 int screen_height = mapscreenbmp->h * mapscreen_single_scale;
473
474 visible_screens.clear();
475 for (int dx = 0; dx < num_screens; dx++)
476 {
477 for (int dy = 0; dy < num_screens; dy++)
478 {
479 int mx = Map.getViewScr()%16 + dx;
480 int my = Map.getViewScr()/16 + dy;
481 if (mx < 0 || mx >= 16 || my < 0 || my >= 9)
482 continue;
483
484 int screen = Map.getViewScr() + dx + dy * 16;
485 if (screen >= MAPSCRS)
486 continue;
487
488 mapscr* scr = Map.Scr(screen);
489 int offx = dx * screen_width;
490 int offy = dy * screen_height;
491 visible_screens.emplace_back(VisibleScreen{dx, dy, offx, offy, scr, screen});
492 }
493 }
494
495 for (int i = 0; i < 6; i++)
496 {
497 mapscreen_valid_layers[i] = false;
498 for (auto& vis_screen : visible_screens)
499 {
500 mapscreen_valid_layers[i] |= vis_screen.scr->layermap[i] > 0;
501 }
502 }
503 }
504
505 int32_t readsize, writesize;
506 bool fake_pack_writing=false;
507
508 int32_t showxypos_x;
509 int32_t showxypos_y;
510 int32_t showxypos_w;
511 int32_t showxypos_h;
512 int32_t showxypos_color;
513 int32_t showxypos_ffc=-1000;
514 bool showxypos_icon=false;
515
516 int32_t showxypos_cursor_x;
517 int32_t showxypos_cursor_y;
518 bool showxypos_cursor_icon=false;
519 int32_t showxypos_cursor_color;
520 bool showxypos_dummy = false;
521
522 bool canfill=true; //to prevent double-filling (which stops undos)
523 int32_t lens_hint_item[MAXITEMS][2]; //aclk, aframe
524 int32_t lens_hint_weapon[MAXWPNS][5]; //aclk, aframe, dir, x, y
525 //int32_t mode, switch_mode, orig_mode;
526 int32_t tempmode=GFX_AUTODETECT;
527 RGB_MAP zq_rgb_table;
528 COLOR_MAP trans_table, trans_table2;
529 MIDI *song=NULL;
530 BITMAP *menu1, *menu3, *mapscreenbmp, *tmp_scr, *screen2, *mouse_bmp[MOUSE_BMP_MAX][4], *mouse_bmp_1x[MOUSE_BMP_MAX][4], *icon_bmp[ICON_BMP_MAX][4], *flag_bmp[16][4], *select_bmp[2], *dmapbmp_small, *dmapbmp_large;
531 BITMAP *arrow_bmp[MAXARROWS],*brushbmp, *brushscreen; //*brushshadowbmp;
532 byte *colordata=NULL, *trashbuf=NULL;
533 itemdata *itemsbuf;
534 wpndata *wpnsbuf;
535 comboclass *combo_class_buf;
536 guydata *guysbuf;
537 item_drop_object item_drop_sets[MAXITEMDROPSETS];
538 12 newcombo curr_combo;
539 PALETTE RAMpal;
540 midi_info Midi_Info;
541 bool zq_showpal=false;
542 bool is_compact = false;
543
544 int pixeldb = 1;
545 int infobg = 1;
546 bool large_merged_combopane = false;
547 bool compact_merged_combopane = true;
548 bool large_zoomed_fav = false;
549 bool compact_zoomed_fav = true;
550 bool large_zoomed_cmd = false;
551 bool compact_zoomed_cmd = true;
552
553 bool compact_square_panels = false;
554 int compact_active_panel = 0;
555
556 int combo_col_scale = 1;
557
558 std::vector<std::shared_ptr<zasm_script>> zasm_scripts;
559 script_data *ffscripts[NUMSCRIPTFFC];
560 script_data *itemscripts[NUMSCRIPTITEM];
561 script_data *guyscripts[NUMSCRIPTGUYS];
562 script_data *lwpnscripts[NUMSCRIPTWEAPONS];
563 script_data *ewpnscripts[NUMSCRIPTWEAPONS];
564 script_data *globalscripts[NUMSCRIPTGLOBAL];
565 script_data *genericscripts[NUMSCRIPTSGENERIC];
566 script_data *playerscripts[NUMSCRIPTHERO];
567 script_data *screenscripts[NUMSCRIPTSCREEN];
568 script_data *dmapscripts[NUMSCRIPTSDMAP];
569 script_data *itemspritescripts[NUMSCRIPTSITEMSPRITE];
570 script_data *comboscripts[NUMSCRIPTSCOMBODATA];
571 script_data *subscreenscripts[NUMSCRIPTSSUBSCREEN];
572
573 extern string zScript;
574 char zScriptBytes[512];
575 char zLastVer[512] = { 0 };
576 SAMPLE customsfxdata[WAV_COUNT];
577 uint8_t customsfxflag[WAV_COUNT>>3];
578 int32_t sfxdat=1;
579
580 int32_t onImport_ComboAlias();
581 int32_t onExport_ComboAlias();
582
583 void set_console_state();
584
585 void clearConsole()
586 {
587 if(!console_is_open) return;
588 zscript_coloured_console.cls(CConsoleLoggerEx::COLOR_BACKGROUND_BLACK);
589 zscript_coloured_console.gotoxy(0,0);
590 zscript_coloured_console.cprintf( CConsoleLoggerEx::COLOR_BLUE | CConsoleLoggerEx::COLOR_INTENSITY |
591 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"ZQuest Classic Logging Console\n");
592 }
593
594 void initConsole()
595 {
596 if(console_is_open) return;
597 console_is_open = 1;
598 set_console_state();
599 zscript_coloured_console.Create("ZQuest Classic Logging Console", 600, 200);
600 clearConsole();
601 }
602
603 11 void killConsole()
604 {
605
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!console_is_open) return;
606 console_is_open = 0;
607 set_console_state();
608 zscript_coloured_console.kill();
609 11 }
610
611 int toggleConsole()
612 {
613 console_is_open ? killConsole() : initConsole();
614 zc_set_config("zquest","open_debug_console",console_is_open?1:0);
615 return D_O_K;
616 }
617
618 int showHotkeys()
619 {
620 hotkeys_toggle_display(!hotkeys_is_active());
621 return D_O_K;
622 }
623
624 typedef int32_t (*intF)();
625 typedef struct command_pair
626 {
627 char name[80];
628 int32_t flags;
629 intF command;
630 } command_pair;
631
632 extern map_and_screen map_page[MAX_MAPPAGE_BTNS];
633
634 int32_t do_OpenQuest()
635 {
636 return onOpen();
637 }
638
639 int32_t do_NewQuest()
640 {
641 //clear the panel recent screen buttons to prevent crashes from invalid maps
642 for ( int32_t q = 0; q < 9; q++ )
643 {
644 map_page[q].map = 0;
645 map_page[q].screen = 0;
646 }
647 Map.setCurrMap(0);
648 Map.setCurrScr(0);
649 return onNew();
650 }
651
652 extern int CheckerCol1, CheckerCol2;
653 int32_t alignment_arrow_timer=0;
654 int32_t Flip=0,Combo=0,CSet=2,current_combolist=0,current_comboalist=0,current_cpoollist=0,current_cautolist=0,current_mappage=0;
655 int32_t Flags=0,Flag=0,menutype=(m_block);
656 int MouseScroll = 0, SavePaths = 0, CycleOn = 0, ShowGrid = 0, ShowScreenGrid = 0, ShowRegionGrid = 0, GridColor = 15, ShowCurScreenOutline = 1,
657 CmbCursorCol = 15, TilePgCursorCol = 15, CmbPgCursorCol = 15, TTipHLCol = 13,
658 TileProtection = 0, ComboProtection = 0, NoScreenPreview = 0, MMapCursorStyle = 0,
659 LayerDitherBG = -1, LayerDitherSz = 2, RulesetDialog = 0,
660 EnableTooltips = 0, TooltipsHighlight = 0, ShowFFScripts = 0, ShowSquares = 0,
661 ShowFFCs = 0, ShowInfo = 0, skipLayerWarning = 0,
662 DisableLPalShortcuts = 1, DisableCompileConsole = 0, numericalFlags = 0,
663 ActiveLayerHighlight = 0, DragCenterOfSquares = 0;
664 uint8_t InvalidBG = 0;
665 bool NoHighlightLayer0 = false;
666 int32_t FlashWarpSquare = -1, FlashWarpClk = 0; // flash the destination warp return when ShowSquares is active
667 uint8_t ViewLayer3BG = 0, ViewLayer2BG = 0;
668 int32_t window_width, window_height;
669 bool ShowFPS = false, SaveDragResize = false, DragAspect = false, SaveWinPos=false;
670 bool allowHideMouse = false;
671 double aspect_ratio = LARGE_H / double(LARGE_W);
672 int window_min_width = 0, window_min_height = 0;
673 int32_t ComboBrush = 0; //show the brush instead of the normal mouse
674 int32_t ComboBrushPause = 0; //temporarily disable the combo brush
675 int32_t FloatBrush = 0; //makes the combo brush float a few pixels up and left
676 int AutoBrush = 0; //Drag to size the brush on the combo panes
677 bool AutoBrushRevert = false; //Revert after placing
678 int LinkedScroll = 0;
679 //complete with shadow
680 int32_t OpenLastQuest = 0; //makes the program reopen the quest that was
681 //open at the time you quit
682 int32_t ShowMisalignments = 0; //makes the program display arrows over combos that are
683 //not aligned with the next screen.
684 int32_t AnimationOn = 0; //animate the combos in zquest?
685 int32_t AutoBackupRetention = 0; //use auto-backup feature? if so, how many backups (1-10) to keep
686 int32_t AutoSaveInterval = 0; //how often a timed autosave is made (not overwriting the current file)
687 int32_t UncompressedAutoSaves = 0; //should timed saves be uncompressed/encrypted?
688 int32_t KeyboardRepeatDelay = 0; //the time in milliseconds after holding down a key that the key starts to repeat
689 int32_t KeyboardRepeatRate = 0; //the time in milliseconds between each repetition of a repeated key
690
691 time_t auto_save_time_start, auto_save_time_current;
692 double auto_save_time_diff = 0;
693 int32_t AutoSaveRetention = 0; //how many autosaves of a quest to keep
694 int32_t ImportMapBias = 0; //tells what has precedence on map importing
695 int32_t BrushWidth=1, BrushHeight=1;
696 bool saved=true;
697 bool __debug=false;
698 int32_t LayerMaskInt[7]={0};
699 int32_t CurrentLayer=0;
700 int32_t DuplicateAction[4]={0};
701 int32_t OnlyCheckNewTilesForDuplicates = 0;
702 int32_t try_recovering_missing_scripts = 0;
703
704 uint8_t PreFillTileEditorPage = 0, PreFillComboEditorPage = 0;
705 int32_t DMapEditorLastMaptileUsed = 0;
706
707 /*
708 , HorizontalDuplicateAction;
709 int32_t VerticalDuplicateAction, BothDuplicateAction;
710 */
711 word msg_count = 0;
712 int32_t LeechUpdate = 0;
713 int32_t LeechUpdateTiles = 0;
714 int32_t SnapshotFormat = 0;
715 byte SnapshotScale = 0;
716
717 byte Color = 0;
718 extern int32_t jwin_pal[jcMAX];
719 int32_t gui_colorset=99;
720
721 static int32_t combo_apos=0; //currently selected combo alias
722 int32_t alias_origin=0;
723 int32_t alias_cset_mod=0;
724
725 static int32_t combo_pool_pos=0; //currently selected combo pool
726 bool weighted_cpool = true;
727 bool cpool_prev_visible = false;
728
729 static int32_t combo_auto_pos=0; //currently selected autocombo
730 byte cauto_height = 1;
731
732 bool trip=false;
733
734 int32_t fill_type=1;
735
736 bool first_save=false;
737 char *filepath,*midipath,*datapath,*imagepath,*tmusicpath,*last_timed_save;
738 string helpstr, zstringshelpstr;
739
740 ZCMUSIC *zcmusic = NULL;
741 ZCMIXER *zcmixer = NULL;
742 int32_t midi_volume = 255;
743 extern int32_t prv_mode;
744 int32_t prv_warp = 0;
745 int32_t prv_twon = 0;
746 int32_t ff_combo = 0;
747
748 int32_t Frameskip = 0, RequestedFPS = 60, zqUseWin32Proc = 1;
749 int32_t zqColorDepth = 8;
750 int32_t joystick_index=0;
751
752 11 void set_last_timed_save(char const* buf)
753 {
754
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
11 if(buf && buf[0])
755 {
756 if(buf != last_timed_save)
757 strcpy(last_timed_save, buf);
758 }
759 else
760 {
761 11 last_timed_save[0] = 0;
762 11 buf = nullptr;
763 }
764 11 zc_set_config("zquest","last_timed_save",buf);
765 11 }
766
767 void loadlvlpal(int32_t level);
768 bool get_debug()
769 {
770 return __debug;
771 //return true;
772 }
773
774 void set_debug(bool d)
775 {
776 __debug=d;
777 return;
778 }
779
780 bool handle_quit()
781 {
782 if(onExit()==D_CLOSE)
783 return (exiting_program = true);
784 return false;
785 }
786 bool handle_close_btn_quit()
787 {
788 if(close_button_quit)
789 {
790 close_button_quit=false;
791 return handle_quit();
792 }
793 return false;
794 }
795 // **** Timers ****
796
797 volatile int32_t lastfps=0;
798 volatile int32_t framecnt=0;
799 size_t cpoolbrush_index = 0;
800
801 // quest data
802 12 zquestheader header;
803 byte midi_flags[MIDIFLAGS_SIZE];
804 byte music_flags[MUSICFLAGS_SIZE];
805 byte *quest_file;
806 int32_t msg_strings_size;
807 zctune *customtunes;
808 //emusic *enhancedMusic;
809 ZCHEATS zcheats;
810 byte use_cheats;
811 byte use_tiles;
812 // Note: may not be null-terminated (must refactor writecolordata to fix).
813 char palnames[MAXLEVELS][17];
814 char zquestdat_sig[52];
815 char qstdat_str[2048];
816
817 int32_t gme_track=0;
818
819 int32_t dlevel; // just here until gamedata is properly done
820
821 12 bool bad_version(int32_t ver)
822 {
823
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(ver < 0x170)
824 return true;
825
826 12 return false;
827 12 }
828
829 // These are for drawing eyeballs correctly in combo_tile.
830 zfix HeroModifiedX()
831 {
832 return gui_mouse_x() - 7;
833 }
834 zfix HeroModifiedY()
835 {
836 return gui_mouse_y() - 7;
837 }
838
839
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu import_250_menu
840 48 {
841
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&DMaps", onImport_DMaps },
842
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Combo Table", onImport_Combos },
843
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Combo Alias", onImport_ComboAlias },
844 };
845
846
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu import_graphics
847 180 {
848
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Palettes", onImport_Pals },
849
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
850
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Tileset (&Full)", onImport_Tiles },
851
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Tile Pack", onImport_Tilepack },
852
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "T&ile Pack to...", onImport_Tilepack_To },
853
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
854
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Combo Set (Range)", onImport_Combos },
855
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Combo Pack (Full, 1:1)", onImport_Combopack },
856
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Combo Pack to... (Dest)", onImport_Combopack_To },
857
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
858
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Combo &Alias Pack", onImport_Comboaliaspack },
859
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Combo A&lias Pack to...", onImport_Comboaliaspack_To },
860
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
861
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Doorsets", onImport_Doorset },
862 };
863
864
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu import_menu
865 120 {
866
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Enemies", onImport_Guys },
867
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Map", onImport_Map },
868
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&DMaps", onImport_DMaps },
869
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Strings (.tsv)", onImport_StringsTSV },
870
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "String Table (deprecated)", onImport_Msgs },
871
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
872
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Graphics", &import_graphics },
873
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
874
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "2.50 (Broken)", &import_250_menu },
875 };
876
877
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu export_250_menu
878 60 {
879
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&DMaps", onExport_DMaps },
880
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Combo Table", onExport_Combos },
881
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Combo Alias", onExport_ComboAlias },
882
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Graphics Pack", onExport_ZGP },
883 };
884
885
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu zq_help_menu
886 36 {
887
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Editor Help", onHelp },
888
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Strings Help", onZstringshelp },
889 };
890
891
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu export_graphics
892 144 {
893
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Palettes", onExport_Pals },
894
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
895
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Tileset (&Full)", onExport_Tiles },
896
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Tile Pack", onExport_Tilepack },
897
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
898
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Combo Set", onExport_Combos },
899
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Combo Pack", onExport_Combopack },
900
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
901
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Combo &Alias Pack", onExport_Comboaliaspack },
902
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
903
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Doorsets", onExport_Doorset },
904 };
905
906
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu export_menu
907 132 {
908 #ifdef _WIN32
909 { "&Package", onExport_Package },
910 #endif
911
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Enemies", onExport_Guys },
912
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Map", onExport_Map },
913
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&DMaps", onExport_DMaps },
914
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
915
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Strings (.tsv)", onExport_StringsTSV },
916
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "String Table (deprecated)", onExport_Msgs },
917
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
918
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Graphics", &export_graphics },
919
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
920
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "2.50 (Broken)", &export_250_menu },
921 };
922
923
924
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu recent_menu
925 132 {
926
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
927
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
928
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
929
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
930
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
931
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
932
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
933
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
934
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
935
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
936 };
937 static char rec_menu_fullpaths[10][512];
938 static char rec_menu_strs[10][64];
939
940 int32_t customOpen(char const* path);
941 void do_recent_quest(uint32_t ind)
942 {
943 if(ind > 9) return;
944 strcpy(temppath, rec_menu_fullpaths[ind]);
945 customOpen(temppath);
946 }
947 int32_t do_RecentQuest_0() { do_recent_quest(0); return D_O_K; }
948 int32_t do_RecentQuest_1() { do_recent_quest(1); return D_O_K; }
949 int32_t do_RecentQuest_2() { do_recent_quest(2); return D_O_K; }
950 int32_t do_RecentQuest_3() { do_recent_quest(3); return D_O_K; }
951 int32_t do_RecentQuest_4() { do_recent_quest(4); return D_O_K; }
952 int32_t do_RecentQuest_5() { do_recent_quest(5); return D_O_K; }
953 int32_t do_RecentQuest_6() { do_recent_quest(6); return D_O_K; }
954 int32_t do_RecentQuest_7() { do_recent_quest(7); return D_O_K; }
955 int32_t do_RecentQuest_8() { do_recent_quest(8); return D_O_K; }
956 int32_t do_RecentQuest_9() { do_recent_quest(9); return D_O_K; }
957
958 2 void refresh_recent_menu()
959 {
960 2 int32_t (*procs[10])(void) = {
961 do_RecentQuest_0, do_RecentQuest_1, do_RecentQuest_2, do_RecentQuest_3,
962 do_RecentQuest_4, do_RecentQuest_5, do_RecentQuest_6,
963 do_RecentQuest_7, do_RecentQuest_8, do_RecentQuest_9
964 };
965
5/8
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
2 static MenuItem nilitem("---",nullptr,nullopt,true);
966
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 20 times.
22 for(auto q = 0; q < 10; ++q)
967 {
968 20 MenuItem& mit = *recent_menu.at(q);
969 20 bool valid = rec_menu_fullpaths[q][0] != '-';
970
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if(valid)
971 mit = MenuItem(rec_menu_strs[q],procs[q]);
972 20 else mit = nilitem;
973 20 }
974 2 }
975
976 1 void load_recent_quests()
977 {
978 1 char configname[64] = "rec_qst_";
979 1 char* ptr = &configname[strlen(configname)];
980 1 char buf[512] = {0};
981
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 1 times.
11 for(auto q = 0; q < 10; ++q)
982 {
983 10 sprintf(ptr, "%d", q); //increment the configname value
984 10 char const* qst_str = zc_get_config("recent",configname,nullptr);
985
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(qst_str[0])
986 {
987 strncpy(rec_menu_fullpaths[q], qst_str, 511);
988 relativize_path(buf, rec_menu_fullpaths[q]);
989 if(strlen(buf) > 62)
990 {
991 buf[60] = buf[61] = buf[62] = '.'; //add "..." as the last 3 characters
992 }
993 strncpy(rec_menu_strs[q], buf, 63);
994 }
995 else
996 {
997 10 strcpy(rec_menu_fullpaths[q], "---");
998 10 strcpy(rec_menu_strs[q], "---");
999 }
1000 10 rec_menu_fullpaths[q][511] = 0;
1001 10 rec_menu_strs[q][63] = 0;
1002 10 }
1003 1 refresh_recent_menu();
1004 1 }
1005
1006 void write_recent_quests()
1007 {
1008 char configname[64] = "rec_qst_";
1009 char* ptr = &configname[strlen(configname)];
1010 for(auto q = 0; q < 10; ++q)
1011 {
1012 sprintf(ptr, "%d", q); //increment the configname value
1013 zc_set_config("recent",configname,(rec_menu_fullpaths[q][0]!='-') ? rec_menu_fullpaths[q] : nullptr);
1014 }
1015 }
1016
1017 void update_recent_quest(char const* path)
1018 {
1019 int32_t ind = -1;
1020 for(auto q = 0; q < 10; ++q)
1021 {
1022 if(!strcmp(path, rec_menu_fullpaths[q]))
1023 {
1024 ind = q;
1025 break;
1026 }
1027 }
1028 if(ind > -1)
1029 {
1030 for(auto q = ind; q > 0; --q)
1031 {
1032 strcpy(rec_menu_fullpaths[q], rec_menu_fullpaths[q-1]);
1033 strcpy(rec_menu_strs[q], rec_menu_strs[q-1]);
1034 }
1035 }
1036 else
1037 {
1038 int32_t free_ind = 9; //if none found, override the last index
1039 for(auto q = 0; q < 9; ++q)
1040 {
1041 if(rec_menu_fullpaths[q][0] == '-')
1042 {
1043 free_ind = q;
1044 break;
1045 }
1046 }
1047
1048 for(auto q = free_ind; q > 0; --q)
1049 {
1050 strcpy(rec_menu_fullpaths[q], rec_menu_fullpaths[q-1]);
1051 strcpy(rec_menu_strs[q], rec_menu_strs[q-1]);
1052 }
1053 }
1054 char buf[512] = {0};
1055 strcpy(rec_menu_fullpaths[0], path);
1056 relativize_path(buf, rec_menu_fullpaths[0]);
1057 if(strlen(buf) > 62)
1058 {
1059 buf[60] = buf[61] = buf[62] = '.'; //add "..." as the last 3 characters
1060 }
1061 strncpy(rec_menu_strs[0], buf, 63);
1062 refresh_recent_menu();
1063 zc_set_config("zquest",last_quest_name,path);
1064 write_recent_quests();
1065 }
1066
1067 void reload_zq_gui()
1068 {
1069 init_custom_fonts();
1070 load_size_poses();
1071 refresh_visible_screens();
1072 update_combobrush();
1073 refresh(rCLEAR|rALL);
1074 }
1075 void change_mapscr_zoom(int delta)
1076 {
1077 int num_screens = Map.getViewSize();
1078 num_screens = std::clamp(num_screens + delta, 1, mapscreen_num_screens_to_draw_max);
1079 Map.setViewSize(num_screens);
1080 std::string qst_cfg_header = qst_cfg_header_from_path(filepath);
1081 zc_set_config(qst_cfg_header.c_str(), "zoom_num_screens", Map.getViewSize());
1082 reload_zq_gui();
1083 }
1084 void toggle_is_compact()
1085 {
1086 is_compact = !is_compact;
1087 zc_set_config("ZQ_GUI","compact_mode",is_compact?1:0);
1088 reload_zq_gui();
1089 }
1090 void toggle_merged_mode()
1091 {
1092 if(is_compact)
1093 {
1094 compact_merged_combopane = !compact_merged_combopane;
1095 zc_set_config("ZQ_GUI","merge_cpane_compact",compact_merged_combopane?1:0);
1096 }
1097 else
1098 {
1099 large_merged_combopane = !large_merged_combopane;
1100 zc_set_config("ZQ_GUI","merge_cpane_large",large_merged_combopane?1:0);
1101 }
1102 reload_zq_gui();
1103 }
1104 void toggle_compact_sqr_mode()
1105 {
1106 compact_square_panels = !compact_square_panels;
1107 zc_set_config("ZQ_GUI","square_panels_compact",compact_square_panels?1:0);
1108 reload_zq_gui();
1109 }
1110 void cycle_compact_sqr(bool down)
1111 {
1112 if(!(is_compact && compact_square_panels))
1113 return;
1114 static const int num_panels = 3;
1115 if(down)
1116 compact_active_panel = (compact_active_panel+1)%num_panels;
1117 else
1118 compact_active_panel = (compact_active_panel-1+num_panels)%num_panels;
1119 reload_zq_gui();
1120 }
1121 void toggle_favzoom_mode()
1122 {
1123 if(is_compact)
1124 {
1125 compact_zoomed_fav = !compact_zoomed_fav;
1126 zc_set_config("ZQ_GUI","zoom_fav_compact",compact_zoomed_fav?1:0);
1127 }
1128 else
1129 {
1130 large_zoomed_fav = !large_zoomed_fav;
1131 zc_set_config("ZQ_GUI","zoom_fav_large",large_zoomed_fav?1:0);
1132 }
1133 reload_zq_gui();
1134 }
1135 void toggle_cmdzoom_mode()
1136 {
1137 if(is_compact)
1138 {
1139 compact_zoomed_cmd = !compact_zoomed_cmd;
1140 zc_set_config("ZQ_GUI","zoom_cmd_compact",compact_zoomed_cmd?1:0);
1141 }
1142 else
1143 {
1144 large_zoomed_cmd = !large_zoomed_cmd;
1145 zc_set_config("ZQ_GUI","zoom_cmd_large",large_zoomed_cmd?1:0);
1146 }
1147 reload_zq_gui();
1148 }
1149
1150 enum
1151 {
1152 MENUID_FILE_SAVE,
1153 MENUID_FILE_SAVEAS,
1154 MENUID_FILE_REVERT,
1155 };
1156
1157
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu file_menu
1158 156 {
1159
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&New", do_NewQuest },
1160
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Open", do_OpenQuest },
1161
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Recent", &recent_menu },
1162
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
1163
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Save", onSave, MENUID_FILE_SAVE },
1164
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Save &as...", onSaveAs, MENUID_FILE_SAVEAS },
1165
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Revert", onRevert, MENUID_FILE_REVERT },
1166
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
1167
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Import", &import_menu },
1168
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Export", &export_menu },
1169 #ifndef __EMSCRIPTEN__
1170
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
1171
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "E&xit", handle_quit },
1172 #endif
1173 };
1174
1175 enum
1176 {
1177 MENUID_MAPS_NEXT,
1178 MENUID_MAPS_PREV,
1179 };
1180
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu maps_menu
1181 72 {
1182
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Goto Map...", onGotoMap },
1183
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Next Map", onIncMap, MENUID_MAPS_NEXT },
1184
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Previous Map", onDecMap, MENUID_MAPS_PREV },
1185
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
1186
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "D&elete Map", onDeleteMap },
1187 };
1188
1189
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu misc_menu
1190 120 {
1191
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "S&ubscreens", onEditSubscreens },
1192
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Shop Types", onShopTypes },
1193
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Bottle Types", onBottleTypes },
1194
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Bottle S&hop Types", onBottleShopTypes },
1195
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Info Types", onInfoTypes },
1196
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Warp Rings", onWarpRings },
1197
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Triforce Pieces", onTriPieces },
1198
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&End String", onEndString },
1199
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Item &Drop Sets", onItemDropSets },
1200 };
1201
1202
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu spr_menu
1203 48 {
1204
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Sprite Data", onCustomWpns },
1205
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Hero", onCustomHero },
1206
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Misc Sprites", onMiscSprites },
1207 };
1208
1209
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 NewMenu colors_menu
1210 48 {
1211
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Main ", onColors_Main },
1212
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Levels ", onColors_Levels },
1213
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Sprites ", onColors_Sprites },
1214 };
1215
1216
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu defs_menu
1217 108 {
1218
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Palettes", onDefault_Pals },
1219
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Tiles", onDefault_Tiles },
1220
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Combos", onDefault_Combos },
1221
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Items", onDefault_Items },
1222
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Enemies", onDefault_Guys },
1223
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Sprite Data", onDefault_Weapons },
1224
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Map Styles", onDefault_MapStyles },
1225
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "SF&X Data", onDefault_SFX },
1226 };
1227
1228 int32_t onEditComboAlias();
1229 int32_t onEditComboPool();
1230 int32_t onEditAutoCombo();
1231
1232
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu graphics_menu
1233 120 {
1234
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Palettes ", &colors_menu },
1235
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Sprites ", &spr_menu },
1236
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Combos", onCombos },
1237
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Tiles", onTiles },
1238
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Game icons", onIcons },
1239
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Misc co&lors", onMiscColors },
1240
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Map styles", onMapStyles },
1241
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Door Combo Sets", onDoorCombos },
1242
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Combo &Aliases", onEditComboAlias },
1243 };
1244
1245
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu audio_menu
1246 48 {
1247
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "SF&X Data", onSelectSFX },
1248
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&MIDIs", onMidis },
1249
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Mis&c SFX", onMiscSFX },
1250 };
1251
1252 void set_rules(byte* newrules);
1253
1254 void call_testqst_dialog();
1255 int32_t onTestQst()
1256 {
1257 call_testqst_dialog();
1258 return D_O_K;
1259 }
1260
1261 int32_t onRulesDlg()
1262 {
1263 call_qr_dialog(21, set_rules);
1264 return D_O_K;
1265 }
1266
1267 int32_t onRulesSearch()
1268 {
1269 call_qrsearch_dialog(set_rules);
1270 return D_O_K;
1271 }
1272
1273 int32_t onZScriptSettings()
1274 {
1275 ScriptRulesDialog(quest_rules, 17, [](byte* newrules)
1276 {
1277 saved = false;
1278 memcpy(quest_rules, newrules, QR_SZ);
1279 unpack_qrs();
1280 }).show();
1281 return D_O_K;
1282 }
1283
1284 void call_zinf_dlg();
1285 int32_t onZInfo()
1286 {
1287 call_zinf_dlg();
1288 return D_O_K;
1289 }
1290
1291
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu quest_menu
1292 204 {
1293
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Options ", onRulesDlg },
1294
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Test", onTestQst },
1295
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Items", onCustomItems },
1296
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Ene&mies", onCustomEnemies },
1297
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Hero", onCustomHero },
1298
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Strings", onStrings },
1299
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&DMaps", onDmaps },
1300
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Regions", onRegions },
1301
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "I&nit Data", onInit },
1302
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Misc D&ata ", &misc_menu },
1303
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&ZInfo", onZInfo },
1304
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
1305
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Graphics ", &graphics_menu },
1306
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "A&udio ", &audio_menu },
1307
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
1308
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "De&faults ", &defs_menu },
1309 };
1310
1311
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu paste_menu
1312 36 {
1313
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Paste &To All", onPasteToAll },
1314
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Paste &All To All", onPasteAllToAll },
1315 };
1316
1317
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu paste_item_menu
1318 156 {
1319
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Undercombo", onPasteUnderCombo },
1320
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Secret Combos", onPasteSecretCombos },
1321
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Freeform Combos", onPasteFFCombos },
1322
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Screen &Data", onPasteScreenData },
1323
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Warps", onPasteWarps },
1324
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Warp &Return", onPasteWarpLocations },
1325
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Enemies", onPasteEnemies },
1326
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Room &Type Data", onPasteRoom },
1327
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Guy/String", onPasteGuy },
1328
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Doo&rs", onPasteDoors },
1329
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Layers", onPasteLayers },
1330
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Palette", onPastePalette },
1331 };
1332
1333 enum
1334 {
1335 MENUID_EDIT_UNDO,
1336 MENUID_EDIT_REDO,
1337 MENUID_EDIT_COPY,
1338 MENUID_EDIT_PASTE,
1339 MENUID_EDIT_PASTEALL,
1340 MENUID_EDIT_ADVPASTE,
1341 MENUID_EDIT_SPECPASTE,
1342 MENUID_EDIT_DELETE,
1343 };
1344
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu edit_menu
1345 132 {
1346
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Undo", onUndo, MENUID_EDIT_UNDO },
1347
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Redo", onRedo, MENUID_EDIT_REDO },
1348
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Copy", onCopy, MENUID_EDIT_COPY },
1349
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Paste", onPaste, MENUID_EDIT_PASTE },
1350
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Paste A&ll", onPasteAll, MENUID_EDIT_PASTEALL },
1351
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Adv. Paste ", &paste_menu, MENUID_EDIT_ADVPASTE },
1352
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Paste &Spec. ", &paste_item_menu, MENUID_EDIT_SPECPASTE },
1353
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Delete", onDelete, MENUID_EDIT_DELETE },
1354
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
1355
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Maps ", &maps_menu },
1356 };
1357
1358
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu drawing_mode_menu
1359 60 {
1360
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Normal", onDrawingModeNormal, dm_normal },
1361
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Combo Alias", onDrawingModeAlias, dm_alias },
1362
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Pool", onDrawingModePool, dm_cpool },
1363
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Auto Combo", onDrawingModeAuto, dm_auto },
1364 };
1365
1366
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu integrity_check_menu
1367 48 {
1368
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&All ", onIntegrityCheckAll },
1369
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Screens ", onIntegrityCheckRooms },
1370
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Warps ", onIntegrityCheckWarps },
1371 };
1372
1373
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu quest_reports_menu
1374 108 {
1375
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Bugged Next-> Combo Locations", onBuggedNextComboLocationReport },
1376
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Combo Locations", onComboLocationReport },
1377
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Combo Type Locations", onComboTypeLocationReport },
1378
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Enemy Locations", onEnemyLocationReport },
1379
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Item Locations", onItemLocationReport },
1380
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Script Locations", onScriptLocationReport },
1381
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&What Links Here", onWhatWarpsReport },
1382
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "In&tegrity Check ", &integrity_check_menu },
1383 };
1384
1385 int32_t onPalFix();
1386 int32_t onPitFix();
1387 int32_t onStrFix()
1388 {
1389 if(get_qr(qr_OLD_STRING_EDITOR_MARGINS))
1390 {
1391 AlertDialog("Fix: Old Margins",
1392 "Fixing margins may cause strings that used to spill outside the textbox"
1393 " to instead be cut off. Are you sure?",
1394 [&](bool ret,bool)
1395 {
1396 if(ret)
1397 {
1398 set_qr(qr_OLD_STRING_EDITOR_MARGINS, 0);
1399 saved = false;
1400 }
1401 }).show();
1402 }
1403 if(get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT))
1404 {
1405 AlertDialog("Fix: Old Frame Size",
1406 "This will fix the frame size of all strings. No visual changes should occur,"
1407 " as the string width/height will be fixed, but the compat QR will also be unchecked.",
1408 [&](bool ret,bool)
1409 {
1410 if(ret)
1411 {
1412 for(auto q = 0; q < msg_count; ++q)
1413 {
1414 MsgStrings[q].w += 16;
1415 MsgStrings[q].h += 16;
1416 }
1417 set_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT, 0);
1418 saved = false;
1419 }
1420 }).show();
1421 }
1422 return D_O_K;
1423 }
1424
1425 int32_t onRemoveOldArrivalSquare();
1426 enum
1427 {
1428 MENUID_FIXTOOL_OLDSTRING,
1429 };
1430
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu fixtools_menu
1431 96 {
1432
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Color Set Fix", onCSetFix },
1433
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Liquid Solidity Fix", onWaterSolidity },
1434
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Effect Square Fix", onEffectFix },
1435
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Level Palette Fix", onPalFix },
1436
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Pit and Liquid Damage Fix", onPitFix },
1437
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Old Strings Fix", onStrFix, MENUID_FIXTOOL_OLDSTRING },
1438
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Green Arrival Square Fix", onRemoveOldArrivalSquare },
1439 };
1440
1441
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu tool_menu
1442 132 {
1443
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Combo &Flags", onFlags, nullopt, MFL_EXIT_PRE_PROC },
1444
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Fix &Tools ", &fixtools_menu },
1445
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&NES Dungeon Template", onTemplate },
1446
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Apply Template to All", onReTemplate },
1447
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
1448
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Preview Mode", onPreviewMode },
1449
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Drawing &Mode ", &drawing_mode_menu },
1450
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
1451
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&List Combos Used", onUsedCombos },
1452
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Quest Reports ", &quest_reports_menu },
1453 };
1454
1455 int32_t onLayer3BG()
1456 {
1457 ViewLayer3BG = ViewLayer3BG ? 0 : 1;
1458 zc_set_config("zquest","layer3_bg",ViewLayer3BG);
1459 return D_O_K;
1460 }
1461 int32_t onLayer2BG()
1462 {
1463 ViewLayer2BG = ViewLayer2BG ? 0 : 1;
1464 zc_set_config("zquest","layer2_bg",ViewLayer2BG);
1465 return D_O_K;
1466 }
1467 int onGridToggle();
1468 enum
1469 {
1470 MENUID_VIEW_WALKABILITY,
1471 MENUID_VIEW_FLAGS,
1472 MENUID_VIEW_CSET,
1473 MENUID_VIEW_TYPES,
1474 MENUID_VIEW_INFO,
1475 MENUID_VIEW_SQUARES,
1476 MENUID_VIEW_FFCS,
1477 MENUID_VIEW_SCRIPTNAMES,
1478 MENUID_VIEW_GRID,
1479 MENUID_VIEW_SCREENGRID,
1480 MENUID_VIEW_REGIONGRID,
1481 MENUID_VIEW_CURSCROUTLINE,
1482 MENUID_VIEW_DARKNESS,
1483 MENUID_VIEW_L2BG,
1484 MENUID_VIEW_L3BG,
1485 MENUID_VIEW_LAYERHIGHLIGHT,
1486 };
1487
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 NewMenu view_menu
1488 252 {
1489
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "View &Map...", onViewMap },
1490
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "View &Palette", onShowPal },
1491
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
1492
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Show &Walkability", onShowWalkability, MENUID_VIEW_WALKABILITY },
1493
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Show &Flags", onShowFlags, MENUID_VIEW_FLAGS },
1494
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Show &CSets", onShowCSet, MENUID_VIEW_CSET },
1495
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Show &Types", onShowCType, MENUID_VIEW_TYPES },
1496
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
1497
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Show Screen &Info", onToggleShowInfo, MENUID_VIEW_INFO },
1498
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Show &Squares", onToggleShowSquares, MENUID_VIEW_SQUARES },
1499
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Show FFCs", onToggleShowFFCs, MENUID_VIEW_FFCS },
1500
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Show Script &Names", onToggleShowScripts, MENUID_VIEW_SCRIPTNAMES },
1501
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Show &Grid", onGridToggle, MENUID_VIEW_GRID },
1502
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Show Screen G&rid", onToggleScreenGrid, MENUID_VIEW_SCREENGRID },
1503
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Show Region Grid", onToggleRegionGrid, MENUID_VIEW_REGIONGRID },
1504
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Show Current Screen Outline", onToggleCurrentScreenOutline, MENUID_VIEW_CURSCROUTLINE },
1505
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Show &Darkness", onShowDarkness, MENUID_VIEW_DARKNESS },
1506
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Layer 2 is Background", onLayer2BG, MENUID_VIEW_L2BG },
1507
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Layer 3 is Background", onLayer3BG, MENUID_VIEW_L3BG },
1508
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Highlight Current Layer", onToggleHighlightLayer, MENUID_VIEW_LAYERHIGHLIGHT },
1509 };
1510
1511 11 void set_rules(byte* newrules)
1512 {
1513 11 saved = false;
1514
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(newrules != quest_rules)
1515 memcpy(quest_rules, newrules, QR_SZ);
1516 11 unpack_qrs();
1517
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2 times.
11 if(!get_qr(qr_ALLOW_EDITING_COMBO_0))
1518 {
1519 2 combobuf[0].walk = 0xF0;
1520 2 combobuf[0].type = 0;
1521 2 combobuf[0].flag = 0;
1522 2 }
1523
1524 // For 2.50.0 and 2.50.1
1525
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2 times.
11 if(get_qr(qr_VERYFASTSCROLLING))
1526 2 set_qr(qr_FASTDNGN, 1);
1527 11 }
1528
1529 int32_t onSelectFFCombo();
1530
1531 void onScreenNotes()
1532 {
1533 edit_screen_notes(Map.CurrScr(), Map.getCurrMap(), Map.getCurrScr());
1534 }
1535
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu data_menu
1536 216 {
1537
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Screen Data", onScrData },
1538
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Freeform Combos", onSelectFFCombo },
1539
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "La&yers", onLayers },
1540
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Tile Warp", onTileWarp },
1541
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Side &Warp", onSideWarp },
1542
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Secret &Combos", onSecretCombo },
1543
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Under Combo", onUnderCombo },
1544
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Doors", onDoors },
1545
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Maze Path", onPath },
1546
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
1547
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Item", onItem },
1548
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Enemies", onEnemies },
1549
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Palette", onScreenPalette },
1550
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
1551
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Room Data", onRoom },
1552
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Notes", onScreenNotes },
1553
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Browse Notes", browse_screen_notes },
1554 };
1555
1556
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu tunes_menu
1557 252 {
1558
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "ZC Forever", playZCForever },
1559
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Wind Fish", playTune1 },
1560
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Overworld", playTune2 },
1561
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Hyrule Castle", playTune3 },
1562
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Lost Woods", playTune4 },
1563
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Great Sea", playTune5 },
1564
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "East Hyrule", playTune6 },
1565
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Dancing Dragon", playTune7 },
1566
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Stone Tower", playTune8 },
1567
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Villages", playTune9 },
1568
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Swamp + Desert", playTune10 },
1569
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Outset Island", playTune11 },
1570
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Kakariko Village", playTune12 },
1571
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Clock Town", playTune13 },
1572
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Temple", playTune14 },
1573
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Dark World", playTune15 },
1574
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Dragon Roost", playTune16 },
1575
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Horse Race", playTune17 },
1576
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Credits", playTune18 },
1577
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Zelda's Lullaby", playTune19 },
1578 };
1579
1580 enum
1581 {
1582 MENUID_MEDIA_TUNES,
1583 MENUID_MEDIA_PLAYMUSIC,
1584 MENUID_MEDIA_CHANGETRACK,
1585 };
1586
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu media_menu
1587 60 {
1588
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Ambient Music ", &tunes_menu, MENUID_MEDIA_TUNES },
1589
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Play music", playMusic, MENUID_MEDIA_PLAYMUSIC },
1590
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Change track", changeTrack, MENUID_MEDIA_CHANGETRACK },
1591
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Stop tunes", stopMusic },
1592 };
1593
1594 enum
1595 {
1596 MENUID_ETC_VIDMODE,
1597 MENUID_ETC_FULLSCREEN,
1598 MENUID_ETC_DEBUG_CONSOLE,
1599 };
1600
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu etc_menu
1601 192 {
1602
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Help", &zq_help_menu },
1603
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&About", onAbout },
1604
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Video Mode", onZQVidMode, MENUID_ETC_VIDMODE },
1605
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Options...", onOptions },
1606
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Hotkeys...", do_zq_hotkey_dialog },
1607
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&List Hotkeys...", do_zq_list_hotkeys_dialog },
1608
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Fullscreen", onFullScreen, MENUID_ETC_FULLSCREEN },
1609
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
1610
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&View Pic...", onViewPic },
1611
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Media", &media_menu },
1612
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
1613
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Debug Console", toggleConsole, MENUID_ETC_DEBUG_CONSOLE },
1614
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Clear Quest Filepath", onClearQuestFilepath },
1615
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Take ZQ Snapshot", onMenuSnapshot },
1616
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Take &Screen Snapshot", onMapscrSnapshot },
1617 };
1618
1619
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu zscript_menu
1620 60 {
1621
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Compile &ZScript...", onCompileScript },
1622
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 {},
1623
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Compiler Settings", onZScriptCompilerSettings },
1624
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Quest Script Settings", onZScriptSettings },
1625 };
1626
1627 void set_console_state()
1628 {
1629 etc_menu.select_uid(MENUID_ETC_DEBUG_CONSOLE, console_is_open);
1630 }
1631
1632
3/16
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
12 NewMenu foo_menu{{"FOO",[](){InfoDialog("PLACEHOLDER","THIS IS A PLACEHOLDER").show();}}};
1633
1634
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 TopMenu the_menu
1635 108 {
1636
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&File", &file_menu },
1637
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Quest", &quest_menu },
1638
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Edit", &edit_menu },
1639
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&View", &view_menu },
1640
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Tools", &tool_menu },
1641
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&Screen", &data_menu },
1642
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "&ZScript", &zscript_menu },
1643
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Et&C", &etc_menu },
1644 };
1645
1646 void rebuild_trans_table();
1647 int32_t launchPicViewer(BITMAP **pictoview, PALETTE pal,
1648 int32_t *px2, int32_t *py2, double *scale, bool isviewingmap, bool skipmenu = false);
1649
1650 int32_t onResetTransparency()
1651 {
1652 restore_mouse();
1653 rebuild_trans_table();
1654 jwin_alert("Notice","Translucency Table Rebuilt",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
1655
1656 refresh(rALL);
1657 return D_O_K;
1658 }
1659
1660 int32_t onFullScreen()
1661 {
1662 get_palette(RAMpal);
1663 bool windowed=is_windowed_mode()!=0;
1664 all_toggle_fullscreen(windowed);
1665
1666 gui_mouse_focus=0;
1667 gui_bg_color=jwin_pal[jcBOX];
1668 gui_fg_color=jwin_pal[jcBOXFG];
1669 MouseSprite::set(ZQM_NORMAL);
1670 zc_set_palette(RAMpal);
1671 position_mouse(zq_screen_w/2,zq_screen_h/2);
1672 set_display_switch_mode(SWITCH_BACKGROUND);
1673 set_display_switch_callback(SWITCH_OUT, switch_out);
1674 set_display_switch_callback(SWITCH_IN, switch_in);
1675 zc_set_config("zquest","fullscreen", is_windowed_mode() ? 0 : 1);
1676 return D_REDRAW;
1677 }
1678
1679 int32_t onEnter()
1680 {
1681 if(key[KEY_ALT]||key[KEY_ALTGR])
1682 {
1683 return onFullScreen();
1684 }
1685
1686 return D_O_K;
1687 }
1688
1689 //PROC, x, y, w, h, fg, bg, key, flags, d1, d2, *dp, *dp2, *dp3
1690
1691 //*text, (*proc), *child, flags, *dp
1692
1693 void run_zq_frame();
1694 int32_t d_nbmenu_proc(int32_t msg,DIALOG *d,int32_t c);
1695
1696
1697 /*int32_t onY()
1698 {
1699 return D_O_K;
1700 }*/
1701
1702 int32_t onToggleGrid(bool color)
1703 {
1704 if(color)
1705 {
1706 GridColor=(GridColor+8)%16;
1707 zc_set_config("zquest", "grid_color", GridColor);
1708 }
1709 else
1710 {
1711 ShowGrid=!ShowGrid;
1712 zc_set_config("zquest","show_grid",ShowGrid);
1713 }
1714
1715 return D_O_K;
1716 }
1717
1718 int onGridToggle()
1719 {
1720 return onToggleGrid(CHECK_CTRL_CMD);
1721 }
1722
1723 int32_t onToggleScreenGrid()
1724 {
1725 ShowScreenGrid=!ShowScreenGrid;
1726 zc_set_config("zquest","show_screen_grid",ShowScreenGrid);
1727 return D_O_K;
1728 }
1729
1730 int32_t onToggleRegionGrid()
1731 {
1732 ShowRegionGrid=!ShowRegionGrid;
1733 zc_set_config("zquest","show_region_grid",ShowRegionGrid);
1734 return D_O_K;
1735 }
1736
1737 int32_t onToggleCurrentScreenOutline()
1738 {
1739 ShowCurScreenOutline=!ShowCurScreenOutline;
1740 zc_set_config("zquest","show_current_screen_outline",ShowCurScreenOutline);
1741 return D_O_K;
1742 }
1743
1744 int32_t onToggleShowScripts()
1745 {
1746 ShowFFScripts=!ShowFFScripts;
1747 zc_set_config("zquest","showffscripts",ShowFFScripts);
1748 return D_O_K;
1749 }
1750
1751 int32_t onToggleShowFFCs()
1752 {
1753 ShowFFCs=!ShowFFCs;
1754 zc_set_config("zquest","showffcs",ShowFFCs);
1755 return D_O_K;
1756 }
1757
1758 int32_t onToggleShowSquares()
1759 {
1760 ShowSquares=!ShowSquares;
1761 zc_set_config("zquest","showsquares",ShowSquares);
1762 return D_O_K;
1763 }
1764
1765 int32_t onToggleShowInfo()
1766 {
1767 ShowInfo=!ShowInfo;
1768 zc_set_config("zquest","showinfo",ShowInfo);
1769 return D_O_K;
1770 }
1771
1772 int32_t onToggleHighlightLayer()
1773 {
1774 ActiveLayerHighlight = ActiveLayerHighlight ? 0 : 1;
1775 zc_set_config("zquest","hl_active_lyr",ActiveLayerHighlight);
1776 return D_O_K;
1777 }
1778
1779 int onKeySlash()
1780 {
1781 if(key[KEY_LSHIFT] || key[KEY_RSHIFT])
1782 {
1783 onAbout();
1784 }
1785 return D_O_K;
1786 }
1787
1788 int onAKey()
1789 {
1790 if(prv_mode)
1791 Map.set_prvadvance(1);
1792 return D_O_K;
1793 }
1794
1795 int onReloadPreview()
1796 {
1797 if(prv_mode)
1798 {
1799 Map.set_prvscr(Map.get_prv_map(), Map.get_prv_scr());
1800 Map.set_prvcmb(0);
1801 }
1802 return D_O_K;
1803 }
1804 int onSecretsPreview()
1805 {
1806 if(prv_mode)
1807 {
1808 Map.prv_secrets(false);
1809 refresh(rALL);
1810 }
1811 return D_O_K;
1812 }
1813
1814 int onSKey()
1815 {
1816 if(CHECK_CTRL_CMD)
1817 {
1818 if(key[KEY_LSHIFT] || key[KEY_RSHIFT])
1819 {
1820 onSaveAs();
1821 }
1822 else
1823 {
1824 if(!saved)
1825 onSave();
1826 }
1827 }
1828 else if(prv_mode)
1829 {
1830 Map.prv_secrets(false);
1831 refresh(rALL);
1832 }
1833 else onStrings();
1834 return D_O_K;
1835 }
1836 int onSetNewLayer(int newlayer)
1837 {
1838 CurrentLayer = newlayer;
1839 refresh(rALL);
1840 return D_O_K;
1841 }
1842 void lpal_dsa()
1843 {
1844 info_dsa("Level Palette Shortcuts",
1845 "You currently have level palette shortcuts disabled."
1846 " These can be re-enabled in 'Etc->Options', on the toggle 'Disable Level Palette Shortcuts'.",
1847 "dsa_lpal");
1848 }
1849 int onScreenLPal(int lpal)
1850 {
1851 if(DisableLPalShortcuts)
1852 {
1853 lpal_dsa();
1854 return D_O_K;
1855 }
1856 saved=false;
1857 Map.setcolor(lpal);
1858 refresh(rSCRMAP);
1859 return D_O_K;
1860 }
1861
1862 int32_t onPressEsc()
1863 {
1864 if(zoomed_minimap)
1865 mmap_set_zoom(false);
1866 else return onExit();
1867 return D_O_K;
1868 }
1869
1870 static DIALOG dialogs[] =
1871 {
1872 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
1873 { d_nbmenu_proc, 0, 0, 0, 13, 0, 0, 0, D_USER, 0, 0, (void *) &the_menu, NULL, NULL },
1874 { d_zq_hotkey_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
1875
1876 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onHelp, NULL, NULL },
1877 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_ESC, 0, (void *) onPressEsc, NULL, NULL },
1878 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 39, 0, 0, 0, (void *) onUsedCombos, NULL, NULL },
1879 { d_vsync_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
1880 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
1881 };
1882
1883
1884 int32_t onDecColour()
1885 {
1886 if ( CHECK_CTRL_CMD )
1887 {
1888 return onDecScrPal16();
1889 }
1890
1891 else if ( key[KEY_LSHIFT] || key[KEY_RSHIFT] )
1892 {
1893 return onDecScrPal();
1894 }
1895
1896 else
1897 {
1898 return onDecreaseCSet();
1899 }
1900 }
1901
1902 int32_t onIncColour()
1903 {
1904
1905 if ( CHECK_CTRL_CMD )
1906 {
1907 return onIncScrPal16();
1908 }
1909
1910 else if ( key[KEY_LSHIFT] || key[KEY_RSHIFT] )
1911 {
1912 return onIncScrPal();
1913 }
1914
1915 else
1916 {
1917 return onIncreaseCSet();
1918 }
1919 }
1920
1921 static DIALOG getnum_dlg[] =
1922 {
1923 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
1924 12 { jwin_win_proc, 80, 80, 160, 72, vc(0), vc(11), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
1925 12 { jwin_rtext_proc, 114, 104+4, 48, 8, jwin_pal[jcBOXFG], jwin_pal[jcBOX], 0, 0, 0, 0, (void *) "Value:", NULL, NULL },
1926 12 { jwin_edit_proc, 168, 104, 48, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
1927 12 { jwin_button_proc, 90, 126, 61, 21, vc(0), vc(11), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
1928 12 { jwin_button_proc, 170, 126, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
1929 12 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
1930 12 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
1931 };
1932
1933 int32_t getnumber(const char *prompt,int32_t initialval)
1934 {
1935 cancelgetnum=true;
1936 char buf[20];
1937 sprintf(buf,"%d",initialval);
1938 getnum_dlg[0].dp=(void *)prompt;
1939 getnum_dlg[0].dp2=get_zc_font(font_lfont);
1940 getnum_dlg[2].dp=(void *)buf;
1941
1942 large_dialog(getnum_dlg);
1943
1944 int32_t ret=do_zqdialog(getnum_dlg,2);
1945
1946 if(ret!=0&&ret!=4)
1947 {
1948 cancelgetnum=false;
1949 }
1950
1951 if(ret==3)
1952 return atoi(buf);
1953
1954 return initialval;
1955 }
1956
1957 static DIALOG save_tiles_dlg[] =
1958 {
1959 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
1960
1961
1962 { jwin_win_proc, 0, 0, 120, 100, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Save Tile Pack", NULL, NULL },
1963 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
1964 //for future tabs
1965 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
1966 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
1967 //4
1968 { jwin_text_proc, 10, 28, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "First", NULL, NULL },
1969 { jwin_edit_proc, 55, 26, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
1970 //6
1971 { jwin_text_proc, 10, 46, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Count", NULL, NULL },
1972 { jwin_edit_proc, 55, 44, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
1973 //8
1974 { jwin_button_proc, 15, 72, 36, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Save", NULL, NULL },
1975 { jwin_button_proc, 69, 72, 36, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
1976 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
1977 };
1978
1979
1980 void savesometiles(const char *prompt,int32_t initialval)
1981 {
1982
1983 char firsttile[8], tilecount[8];
1984 int32_t first_tile_id = 0; int32_t the_tile_count = 1;
1985 sprintf(firsttile,"%d",0);
1986 sprintf(tilecount,"%d",1);
1987 //int32_t ret;
1988
1989
1990
1991 save_tiles_dlg[0].dp2 = get_zc_font(font_lfont);
1992
1993 sprintf(firsttile,"%d",0);
1994 sprintf(tilecount,"%d",1);
1995
1996 save_tiles_dlg[5].dp = firsttile;
1997 save_tiles_dlg[7].dp = tilecount;
1998
1999 large_dialog(save_tiles_dlg);
2000
2001 int32_t ret = do_zqdialog(save_tiles_dlg,-1);
2002 jwin_center_dialog(save_tiles_dlg);
2003
2004 if(ret == 8)
2005 {
2006 first_tile_id = vbound(atoi(firsttile), 0, NEWMAXTILES);
2007 the_tile_count = vbound(atoi(tilecount), 1, NEWMAXTILES-first_tile_id);
2008 if(prompt_for_new_file_compat("Save ZTILE(.ztile)", "ztile", NULL,datapath,false))
2009 {
2010 char name[PATH_MAX];
2011 extract_name(temppath,name,FILENAMEALL);
2012 PACKFILE *f=pack_fopen_password(temppath,F_WRITE, "");
2013 if(f)
2014 {
2015 writetilefile(f,first_tile_id,the_tile_count);
2016 pack_fclose(f);
2017 char tmpbuf[PATH_MAX+20]={0};
2018 sprintf(tmpbuf,"Saved %s",name);
2019 jwin_alert("Success!",tmpbuf,NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2020 }
2021 }
2022 }
2023 }
2024
2025 static DIALOG read_tiles_dlg[] =
2026 {
2027 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
2028
2029
2030 { jwin_win_proc, 0, 0, 120, 100, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Load Tilepack To:", NULL, NULL },
2031 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
2032 //for future tabs
2033 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2034 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2035 //4
2036 { jwin_text_proc, 10, 28, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Starting at:", NULL, NULL },
2037 { jwin_edit_proc, 55, 26, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2038 //6
2039 { d_dummy_proc, 10, 46, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Count", NULL, NULL },
2040 { d_dummy_proc, 55, 44, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2041 //8
2042 { jwin_button_proc, 15, 72, 36, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Load", NULL, NULL },
2043 { jwin_button_proc, 69, 72, 36, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
2044 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
2045 };
2046
2047
2048 void writesometiles_to(const char *prompt,int32_t initialval)
2049 {
2050
2051 char firsttile[8];;
2052 int32_t first_tile_id = 0; int32_t the_tile_count = 1;
2053 sprintf(firsttile,"%d",0);
2054 //int32_t ret;
2055
2056
2057
2058 read_tiles_dlg[0].dp2 = get_zc_font(font_lfont);
2059
2060 sprintf(firsttile,"%d",0);
2061 //sprintf(tilecount,"%d",1);
2062
2063 read_tiles_dlg[5].dp = firsttile;
2064
2065 large_dialog(read_tiles_dlg);
2066
2067 int32_t ret = do_zqdialog(read_tiles_dlg,-1);
2068 jwin_center_dialog(read_tiles_dlg);
2069
2070 if(ret == 8)
2071 {
2072 first_tile_id = vbound(atoi(firsttile), 0, NEWMAXTILES);
2073 //the_tile_count = vbound(atoi(tilecount), 1, NEWMAXTILES-first_tile_id);
2074 if(prompt_for_existing_file_compat("Load ZTILE(.ztile)", "ztile", NULL,datapath,false))
2075 {
2076
2077 char name[256];
2078 extract_name(temppath,name,FILENAMEALL);
2079 PACKFILE *f=pack_fopen_password(temppath,F_READ, "");
2080 if(f)
2081 {
2082
2083 if (!readtilefile_to_location(f,first_tile_id))
2084 {
2085 al_trace("Could not read from .ztile packfile %s\n", name);
2086 jwin_alert("ZTILE File: Error","Could not load the specified Tile.",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2087 }
2088 else
2089 {
2090 jwin_alert("ZTILE File: Success!","Loaded the source tiles to your tile sheets!",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2091 }
2092 pack_fclose(f);
2093 }
2094 }
2095 }
2096 }
2097
2098
2099 static DIALOG save_combofiles_dlg[] =
2100 {
2101 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
2102
2103
2104 { jwin_win_proc, 0, 0, 120, 100, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Save Combo Pack", NULL, NULL },
2105 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
2106 //for future tabs
2107 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2108 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2109 //4
2110 { jwin_text_proc, 10, 28, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "First", NULL, NULL },
2111 { jwin_edit_proc, 55, 26, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2112 //6
2113 { jwin_text_proc, 10, 46, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Count", NULL, NULL },
2114 { jwin_edit_proc, 55, 44, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2115 //8
2116 { jwin_button_proc, 15, 72, 36, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Save", NULL, NULL },
2117 { jwin_button_proc, 69, 72, 36, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
2118 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
2119 };
2120
2121
2122 void savesomecombos(const char *prompt,int32_t initialval)
2123 {
2124
2125 char firsttile[8], tilecount[8];
2126 int32_t first_tile_id = 0; int32_t the_tile_count = 1;
2127 sprintf(firsttile,"%d",0);
2128 sprintf(tilecount,"%d",1);
2129 //int32_t ret;
2130
2131
2132
2133 save_combofiles_dlg[0].dp2 = get_zc_font(font_lfont);
2134
2135 sprintf(firsttile,"%d",0);
2136 sprintf(tilecount,"%d",1);
2137
2138 save_combofiles_dlg[5].dp = firsttile;
2139 save_combofiles_dlg[7].dp = tilecount;
2140
2141 large_dialog(save_combofiles_dlg);
2142
2143 int32_t ret = do_zqdialog(save_combofiles_dlg,-1);
2144 jwin_center_dialog(save_combofiles_dlg);
2145
2146 if(ret == 8)
2147 {
2148 first_tile_id = vbound(atoi(firsttile), 0, (MAXCOMBOS-1));
2149 the_tile_count = vbound(atoi(tilecount), 1, (MAXCOMBOS-1)-first_tile_id);
2150 if(prompt_for_new_file_compat("Save ZCOMBO(.zcombo)", "zcombo", NULL,datapath,false))
2151 {
2152 char name[PATH_MAX];
2153 extract_name(temppath,name,FILENAMEALL);
2154 PACKFILE *f=pack_fopen_password(temppath,F_WRITE, "");
2155 if(f)
2156 {
2157 writecombofile(f,first_tile_id,the_tile_count);
2158 pack_fclose(f);
2159 char tmpbuf[PATH_MAX+20]={0};
2160 sprintf(tmpbuf,"Saved %s",name);
2161 jwin_alert("Success!",tmpbuf,NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2162 }
2163 }
2164 }
2165 }
2166
2167
2168 static DIALOG load_comboset_dlg[] =
2169 {
2170 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
2171
2172
2173 { jwin_win_proc, 0, 0, 120, 100, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Combo Set (Range)", NULL, NULL },
2174 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
2175 //for future tabs
2176 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2177 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2178 //4
2179 { jwin_text_proc, 10, 28, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "First:", NULL, NULL },
2180 { jwin_edit_proc, 55, 26, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2181 //6
2182 { d_dummy_proc, 10, 46, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Count", NULL, NULL },
2183 { d_dummy_proc, 55, 44, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2184 //8
2185 { jwin_button_proc, 15, 72, 36, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Load", NULL, NULL },
2186 { jwin_button_proc, 69, 72, 36, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
2187 { jwin_check_proc, 10, 46, 95, 9, vc(14), vc(1), 0, 0, 1, 0, (void *) "Don't Overwrite", NULL, NULL },
2188
2189 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
2190 };
2191
2192 void writesomecombos(const char *prompt,int32_t initialval)
2193 {
2194
2195 char firsttile[8];
2196 int32_t first_tile_id = 0; int32_t the_tile_count = 1;
2197 sprintf(firsttile,"%d",0);
2198 //int32_t ret;
2199
2200
2201
2202 load_comboset_dlg[0].dp2 = get_zc_font(font_lfont);
2203
2204 sprintf(firsttile,"%d",0);
2205 //sprintf(tilecount,"%d",1);
2206
2207 load_comboset_dlg[5].dp = firsttile;
2208
2209 byte nooverwrite = 0;
2210
2211
2212 large_dialog(load_comboset_dlg);
2213
2214 int32_t ret = do_zqdialog(load_comboset_dlg,-1);
2215 jwin_center_dialog(load_comboset_dlg);
2216
2217 if(ret == 8)
2218 {
2219 if (load_comboset_dlg[10].flags & D_SELECTED) nooverwrite = 1;
2220
2221 al_trace("Nooverwrite is: %d\n", nooverwrite);
2222 first_tile_id = vbound(atoi(firsttile), 0, (MAXCOMBOS-1));
2223 //the_tile_count = vbound(atoi(tilecount), 1, NEWMAXTILES-first_tile_id);
2224 if(prompt_for_existing_file_compat("Load ZCOMBO(.zcombo)", "zcombo", NULL,datapath,false))
2225 {
2226 char name[256];
2227 extract_name(temppath,name,FILENAMEALL);
2228 PACKFILE *f=pack_fopen_password(temppath,F_READ, "");
2229 if(f)
2230 {
2231
2232 if (!readcombofile(f,first_tile_id,nooverwrite))
2233 {
2234 al_trace("Could not read from .zcombo packfile %s\n", name);
2235 jwin_alert("ZCOMBO File: Error","Could not load the specified combos.",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2236 }
2237 else
2238 {
2239 jwin_alert("ZCOMBO File: Success!","Loaded the source combos to your combo pages!",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2240 saved=false;
2241 }
2242 pack_fclose(f);
2243 }
2244
2245 }
2246 }
2247 }
2248
2249 static DIALOG load_combopack_dlg[] =
2250 {
2251 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
2252
2253
2254 { jwin_win_proc, 0, 0, 120, 100, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Import Full Combo Package 1:1", NULL, NULL },
2255 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
2256 //for future tabs
2257 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2258 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2259 //4
2260 { d_dummy_proc, 10, 28, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Starting at:", NULL, NULL },
2261 { d_dummy_proc, 55, 26, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2262 //6
2263 { d_dummy_proc, 10, 46, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Count", NULL, NULL },
2264 { d_dummy_proc, 55, 44, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2265 //8
2266 { jwin_button_proc, 15, 72, 36, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Load", NULL, NULL },
2267 { jwin_button_proc, 69, 72, 36, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
2268 { jwin_check_proc, 10, 42, 95, 9, vc(14), vc(1), 0, 0, 1, 0, (void *) "Don't Overwrite", NULL, NULL },
2269
2270 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
2271 };
2272
2273 void loadcombopack(const char *prompt,int32_t initialval)
2274 {
2275
2276 char firsttile[8];
2277 int32_t first_tile_id = 0; int32_t the_tile_count = 1;
2278 sprintf(firsttile,"%d",0);
2279 //int32_t ret;
2280
2281
2282
2283 load_combopack_dlg[0].dp2 = get_zc_font(font_lfont);
2284
2285 sprintf(firsttile,"%d",0);
2286 //sprintf(tilecount,"%d",1);
2287
2288 load_combopack_dlg[5].dp = firsttile;
2289
2290 byte nooverwrite = 0;
2291
2292
2293 large_dialog(load_combopack_dlg);
2294
2295 int32_t ret = do_zqdialog(load_combopack_dlg,-1);
2296 jwin_center_dialog(load_combopack_dlg);
2297
2298 if(ret == 8)
2299 {
2300 if (load_combopack_dlg[10].flags & D_SELECTED) nooverwrite = 1;
2301
2302 al_trace("Nooverwrite is: %d\n", nooverwrite);
2303 first_tile_id = vbound(atoi(firsttile), 0, (MAXCOMBOS-1));
2304 //the_tile_count = vbound(atoi(tilecount), 1, NEWMAXTILES-first_tile_id);
2305 if(prompt_for_existing_file_compat("Load ZCOMBO(.zcombo)", "zcombo", NULL,datapath,false))
2306 {
2307 char name[256];
2308 extract_name(temppath,name,FILENAMEALL);
2309 PACKFILE *f=pack_fopen_password(temppath,F_READ, "");
2310 if(f)
2311 {
2312 //need dialogue here
2313 if (!readcombofile(f,0,nooverwrite))
2314 {
2315 al_trace("Could not read from .zcombo packfile %s\n", name);
2316 jwin_alert("ZCOMBO File: Error","Could not load the specified Tile.",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2317 }
2318 else
2319 {
2320 jwin_alert("ZCOMBO File: Success!","Loaded the source combos to your combo pages!",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2321 saved=false;
2322 }
2323 }
2324
2325 pack_fclose(f);
2326 }
2327 }
2328 }
2329
2330
2331 static DIALOG read_combopack_dlg[] =
2332 {
2333 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
2334
2335
2336 { jwin_win_proc, 0, 0, 120, 100, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Load Combos (Specific Dest)", NULL, NULL },
2337 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
2338 //for future tabs
2339 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2340 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2341 //4
2342 { jwin_text_proc, 10, 24, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Starting at:", NULL, NULL },
2343 { jwin_edit_proc, 55, 22, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2344 //6
2345 { d_dummy_proc, 10, 46, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Count", NULL, NULL },
2346 { d_dummy_proc, 55, 44, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2347 //8
2348 { jwin_button_proc, 15, 72, 36, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Load", NULL, NULL },
2349 { jwin_button_proc, 69, 72, 36, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
2350 //10
2351 { jwin_check_proc, 10, 58, 95, 9, vc(14), vc(1), 0, 0, 1, 0, (void *) "Don't Overwrite", NULL, NULL },
2352 //11
2353 { jwin_text_proc, 10, 42, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Skip:", NULL, NULL },
2354 //12
2355 { jwin_edit_proc, 55, 40, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2356
2357 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
2358 };
2359
2360
2361
2362 void writesomecombos_to(const char *prompt,int32_t initialval)
2363 {
2364
2365 char firsttile[8];
2366 char skiptile[8];
2367 int32_t first_tile_id = 0; int32_t the_tile_count = 1;
2368 sprintf(firsttile,"%d",0);
2369 //int32_t ret;
2370
2371
2372
2373 read_combopack_dlg[0].dp2 = get_zc_font(font_lfont);
2374
2375 sprintf(skiptile,"%d",0);
2376 //sprintf(tilecount,"%d",1);
2377
2378 read_combopack_dlg[5].dp = firsttile;
2379
2380 byte nooverwrite = 0;
2381 int32_t skipover = 0;
2382
2383 sprintf(skiptile,"%d",0);
2384 //sprintf(tilecount,"%d",1);
2385
2386 read_combopack_dlg[12].dp = skiptile;
2387
2388 large_dialog(read_combopack_dlg);
2389
2390 int32_t ret = do_zqdialog(read_combopack_dlg,-1);
2391 jwin_center_dialog(read_combopack_dlg);
2392
2393 if(ret == 8)
2394 {
2395 if (read_combopack_dlg[10].flags & D_SELECTED) nooverwrite = 1;
2396
2397 first_tile_id = vbound(atoi(firsttile), 0, (MAXCOMBOS-1));
2398 skipover = vbound(atoi(skiptile), 0, (MAXCOMBOS-1));
2399 al_trace("skipover is: %d\n", skipover);
2400 //skipover = vbound(skipover, 0, (MAXCOMBOS-1-skipover));
2401 //the_tile_count = vbound(atoi(tilecount), 1, NEWMAXTILES-first_tile_id);
2402 if(prompt_for_existing_file_compat("Load ZCOMBO(.zcombo)", "zcombo", NULL,datapath,false))
2403 {
2404 char name[256];
2405 extract_name(temppath,name,FILENAMEALL);
2406 PACKFILE *f=pack_fopen_password(temppath,F_READ, "");
2407 if(f)
2408 {
2409
2410 if (!readcombofile_to_location(f,first_tile_id,nooverwrite, skipover))
2411 {
2412 al_trace("Could not read from .zcombo packfile %s\n", name);
2413 jwin_alert("ZCOMBO File: Error","Could not load the specified combos.",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2414 }
2415 else
2416 {
2417 jwin_alert("ZCOMBO File: Success!","Loaded the source combos to your combo pages!",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2418 saved=false;
2419 }
2420 pack_fclose(f);
2421 }
2422
2423 }
2424 }
2425 }
2426
2427
2428
2429 static DIALOG save_dmaps_dlg[] =
2430 {
2431 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
2432
2433
2434 { jwin_win_proc, 0, 0, 120, 100, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Save DMaps (.zdmap)", NULL, NULL },
2435 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
2436 //for future tabs
2437 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2438 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2439 //4
2440 { jwin_text_proc, 10, 28, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "First", NULL, NULL },
2441 { jwin_edit_proc, 55, 26, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2442 //6
2443 { jwin_text_proc, 10, 46, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Last", NULL, NULL },
2444 { jwin_edit_proc, 55, 44, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2445 //8
2446 { jwin_button_proc, 15, 72, 36, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Save", NULL, NULL },
2447 { jwin_button_proc, 69, 72, 36, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
2448 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
2449 };
2450
2451
2452 void savesomedmaps(const char *prompt,int32_t initialval)
2453 {
2454
2455 char firstdmap[8], lastdmap[8];
2456 int32_t first_dmap_id = 0; int32_t last_dmap_id = 0;
2457 sprintf(firstdmap,"%d",0);
2458 sprintf(lastdmap,"%d",1);
2459 //int32_t ret;
2460
2461
2462
2463 save_dmaps_dlg[0].dp2 = get_zc_font(font_lfont);
2464
2465 sprintf(firstdmap,"%d",0);
2466 sprintf(lastdmap,"%d",0);
2467
2468 save_dmaps_dlg[5].dp = firstdmap;
2469 save_dmaps_dlg[7].dp = lastdmap;
2470
2471 large_dialog(save_dmaps_dlg);
2472
2473 int32_t ret = do_zqdialog(save_dmaps_dlg,-1);
2474 jwin_center_dialog(save_dmaps_dlg);
2475
2476 if(ret == 8)
2477 {
2478 first_dmap_id = vbound(atoi(firstdmap), 0, MAXDMAPS-1);
2479 last_dmap_id = vbound(atoi(lastdmap), 0, MAXDMAPS-1);
2480
2481 if ( last_dmap_id < first_dmap_id )
2482 {
2483 int32_t swap = last_dmap_id;
2484 last_dmap_id = first_dmap_id;
2485 first_dmap_id = swap;
2486 }
2487 if(!prompt_for_new_file_compat("Export DMaps (.zdmap)","zdmap",NULL,datapath,false))
2488
2489
2490 saved=false;
2491
2492 PACKFILE *f=pack_fopen_password(temppath,F_WRITE, "");
2493 if(f)
2494 {
2495 if(!writesomedmaps(f,first_dmap_id,last_dmap_id,MAXDMAPS))
2496 {
2497 char buf[PATH_MAX+20],name[PATH_MAX];
2498 extract_name(temppath,name,FILENAMEALL);
2499 sprintf(buf,"Unable to load %s",name);
2500 jwin_alert("Error",buf,NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2501 }
2502 else
2503 {
2504 char name[PATH_MAX];
2505 extract_name(temppath,name,FILENAMEALL);
2506 char tmpbuf[PATH_MAX+20]={0};
2507 sprintf(tmpbuf,"Saved %s",name);
2508 jwin_alert("Success!",tmpbuf,NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2509 }
2510 }
2511 pack_fclose(f);
2512 }
2513 }
2514
2515 static DIALOG save_comboaliasfiles_dlg[] =
2516 {
2517 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
2518
2519
2520 { jwin_win_proc, 0, 0, 120, 100, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Save Combo Alias Pack", NULL, NULL },
2521 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
2522 //for future tabs
2523 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2524 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2525 //4
2526 { jwin_text_proc, 10, 28, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "First", NULL, NULL },
2527 { jwin_edit_proc, 55, 26, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2528 //6
2529 { jwin_text_proc, 10, 46, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Count", NULL, NULL },
2530 { jwin_edit_proc, 55, 44, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2531 //8
2532 { jwin_button_proc, 15, 72, 36, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Save", NULL, NULL },
2533 { jwin_button_proc, 69, 72, 36, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
2534 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
2535 };
2536
2537
2538 void savesomecomboaliases(const char *prompt,int32_t initialval)
2539 {
2540
2541 char firsttile[8], tilecount[8];
2542 int32_t first_tile_id = 0; int32_t the_tile_count = 1;
2543 sprintf(firsttile,"%d",0);
2544 sprintf(tilecount,"%d",1);
2545 //int32_t ret;
2546
2547
2548
2549 save_comboaliasfiles_dlg[0].dp2 = get_zc_font(font_lfont);
2550
2551 sprintf(firsttile,"%d",0);
2552 sprintf(tilecount,"%d",1);
2553
2554 save_comboaliasfiles_dlg[5].dp = firsttile;
2555 save_comboaliasfiles_dlg[7].dp = tilecount;
2556
2557 large_dialog(save_comboaliasfiles_dlg);
2558
2559 int32_t ret = do_zqdialog(save_comboaliasfiles_dlg,-1);
2560 jwin_center_dialog(save_comboaliasfiles_dlg);
2561
2562 if(ret == 8)
2563 {
2564 first_tile_id = vbound(atoi(firsttile), 0, (MAXCOMBOALIASES-1));
2565 the_tile_count = vbound(atoi(tilecount), 1, (MAXCOMBOALIASES-1)-first_tile_id);
2566 if(prompt_for_new_file_compat("Save ZALIAS(.zalias)", "zalias", NULL,datapath,false))
2567 {
2568 char name[PATH_MAX];
2569 extract_name(temppath,name,FILENAMEALL);
2570 PACKFILE *f=pack_fopen_password(temppath,F_WRITE, "");
2571 if(f)
2572 {
2573 writecomboaliasfile(f,first_tile_id,the_tile_count);
2574 pack_fclose(f);
2575 char tmpbuf[PATH_MAX+20]={0};
2576 sprintf(tmpbuf,"Saved %s",name);
2577 jwin_alert("Success!",tmpbuf,NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2578 }
2579 }
2580 }
2581 }
2582
2583
2584 static DIALOG read_comboaliaspack_dlg[] =
2585 {
2586 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
2587
2588
2589 { jwin_win_proc, 0, 0, 120, 100, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Load Combo Pack To:", NULL, NULL },
2590 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
2591 //for future tabs
2592 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2593 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2594 //4
2595 { jwin_text_proc, 10, 28, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Starting at:", NULL, NULL },
2596 { jwin_edit_proc, 55, 26, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2597 //6
2598 { d_dummy_proc, 10, 46, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Count", NULL, NULL },
2599 { d_dummy_proc, 55, 44, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2600 //8
2601 { jwin_button_proc, 15, 72, 36, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Load", NULL, NULL },
2602 { jwin_button_proc, 69, 72, 36, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
2603 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
2604 };
2605
2606
2607 void writesomecomboaliases_to(const char *prompt,int32_t initialval)
2608 {
2609
2610 char firsttile[8];;
2611 int32_t first_tile_id = 0; int32_t the_tile_count = 1;
2612 sprintf(firsttile,"%d",0);
2613 //int32_t ret;
2614
2615
2616
2617 read_comboaliaspack_dlg[0].dp2 = get_zc_font(font_lfont);
2618
2619 sprintf(firsttile,"%d",0);
2620 //sprintf(tilecount,"%d",1);
2621
2622 read_comboaliaspack_dlg[5].dp = firsttile;
2623
2624 large_dialog(read_comboaliaspack_dlg);
2625
2626 int32_t ret = do_zqdialog(read_comboaliaspack_dlg,-1);
2627 jwin_center_dialog(read_comboaliaspack_dlg);
2628
2629 if(ret == 8)
2630 {
2631 first_tile_id = vbound(atoi(firsttile), 0, (MAXCOMBOALIASES-1));
2632 //the_tile_count = vbound(atoi(tilecount), 1, NEWMAXTILES-first_tile_id);
2633 if(prompt_for_existing_file_compat("Load ZALIAS(.zalias)", "zalias", NULL,datapath,false))
2634 {
2635 char name[256];
2636 extract_name(temppath,name,FILENAMEALL);
2637 PACKFILE *f=pack_fopen_password(temppath,F_READ, "");
2638 if(f)
2639 {
2640
2641 if (!readcomboaliasfile_to_location(f,first_tile_id))
2642 {
2643 al_trace("Could not read from .zcombo packfile %s\n", name);
2644 jwin_alert("ZALIAS File: Error","Could not load the specified combo aliases.",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2645 }
2646 else
2647 {
2648 jwin_alert("ZALIAS File: Success!","Loaded the source combos to your combo alias table!",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2649 saved=false;
2650 }
2651 pack_fclose(f);
2652 }
2653 }
2654 }
2655 }
2656
2657
2658
2659
2660 //Doorsets
2661
2662 static DIALOG save_doorset_dlg[] =
2663 {
2664 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
2665 { jwin_win_proc, 0, 0, 120, 100, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Save Doorset", NULL, NULL },
2666 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
2667 //for future tabs
2668 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2669 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2670 //4
2671 { jwin_text_proc, 10, 28, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "First", NULL, NULL },
2672 { jwin_edit_proc, 55, 26, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2673 //6
2674 { jwin_text_proc, 10, 46, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Count", NULL, NULL },
2675 { jwin_edit_proc, 55, 44, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2676 //8
2677 { jwin_button_proc, 15, 72, 36, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Save", NULL, NULL },
2678 { jwin_button_proc, 69, 72, 36, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
2679 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
2680 };
2681
2682
2683 void do_exportdoorset(const char *prompt,int32_t initialval)
2684 {
2685 char firstdoor[8], doorct[8];
2686 int32_t first_doorset_id = 0; int32_t the_doorset_count = 1;
2687 sprintf(firstdoor,"%d",0);
2688 sprintf(doorct,"%d",1);
2689 //int32_t ret;
2690 save_doorset_dlg[0].dp2 = get_zc_font(font_lfont);
2691
2692 sprintf(firstdoor,"%d",0);
2693 sprintf(doorct,"%d",1);
2694
2695 save_doorset_dlg[5].dp = firstdoor;
2696 save_doorset_dlg[7].dp = doorct;
2697
2698 large_dialog(save_doorset_dlg);
2699
2700 int32_t ret = do_zqdialog(save_doorset_dlg,-1);
2701 jwin_center_dialog(save_doorset_dlg);
2702
2703 if(ret == 8) //OK
2704 {
2705 /* sanity bounds
2706 first_doorset_id = vbound(atoi(firstdoor), 0, (MAXCOMBOS-1));
2707 the_doorset_count = vbound(atoi(doorct), 1, (MAXCOMBOS-1)-first_doorset_id);
2708 */
2709 if(prompt_for_new_file_compat("Save ZDOORS(.zdoors)", "zdoors", NULL,datapath,false))
2710 {
2711 char name[256];
2712 extract_name(temppath,name,FILENAMEALL);
2713 PACKFILE *f=pack_fopen_password(temppath,F_WRITE, "");
2714 if(f)
2715 {
2716 writezdoorsets(f,first_doorset_id,the_doorset_count);
2717 pack_fclose(f);
2718 char tmpbuf[512]={0};
2719 sprintf(tmpbuf,"Saved %s",name);
2720 jwin_alert("Success!",tmpbuf,NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2721 }
2722 }
2723 }
2724 }
2725
2726 static DIALOG load_doorset_dlg[] =
2727 {
2728 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
2729 { jwin_win_proc, 0, 0, 120, 124, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Door Set (Range)", NULL, NULL },
2730 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
2731 //for future tabs
2732 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2733 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
2734 //4
2735 { jwin_text_proc, 10, 28, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "First:", NULL, NULL },
2736 { jwin_edit_proc, 55, 26, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2737 //6
2738 { jwin_text_proc, 10, 46, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Count", NULL, NULL },
2739 { jwin_edit_proc, 55, 44, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2740 //8
2741 { jwin_button_proc, 15, 92, 36, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Load", NULL, NULL },
2742 { jwin_button_proc, 69, 92, 36, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
2743 //10
2744 { jwin_text_proc, 10, 64, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Dest", NULL, NULL },
2745 { jwin_edit_proc, 55, 63, 40, 16, vc(12), vc(1), 0, 0, 63, 0, NULL, NULL, NULL },
2746 //8
2747
2748 // { jwin_check_proc, 10, 46, 95, 9, vc(14), vc(1), 0, 0, 1, 0, (void *) "Don't Overwrite", NULL, NULL },
2749
2750 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
2751 };
2752
2753 void do_importdoorset(const char *prompt,int32_t initialval)
2754 {
2755
2756 char firstdoor[8], doorct[8], destid[8];
2757 int32_t first_doorset_id = 0; int32_t the_doorset_count = 1;
2758 int32_t the_dest_id = 0;
2759 sprintf(firstdoor,"%d",0);
2760 sprintf(doorct,"%d",1);
2761 sprintf(destid,"%d",0);
2762 //int32_t ret;
2763
2764 save_doorset_dlg[0].dp2 = get_zc_font(font_lfont);
2765
2766 load_doorset_dlg[5].dp = firstdoor;
2767 load_doorset_dlg[7].dp = doorct;
2768 load_doorset_dlg[11].dp = destid;
2769
2770 byte nooverwrite = 0;
2771
2772 large_dialog(load_doorset_dlg);
2773
2774 int32_t ret = do_zqdialog(load_doorset_dlg,-1);
2775 jwin_center_dialog(load_doorset_dlg);
2776
2777 if(ret == 8) //OK
2778 {
2779 //if (load_doorset_dlg[10].flags & D_SELECTED) nooverwrite = 1;
2780
2781 //sanity bound
2782 first_doorset_id = vbound(atoi(firstdoor), 0, door_combo_set_count);
2783 the_doorset_count = vbound(atoi(doorct), 1, door_combo_set_count);
2784 the_dest_id = vbound(atoi(destid), 0, door_combo_set_count);
2785 if(prompt_for_existing_file_compat("Load ZDOORS(.zdoors)", "zdoors", NULL,datapath,false))
2786 {
2787 char name[256];
2788 extract_name(temppath,name,FILENAMEALL);
2789 PACKFILE *f=pack_fopen_password(temppath,F_READ, "");
2790 if(f)
2791 {
2792 int32_t ret = readzdoorsets(f,first_doorset_id,the_doorset_count, the_dest_id);
2793
2794 if (!ret)
2795 {
2796 al_trace("Could not read from .zdoors packfile %s\n", name);
2797 jwin_alert("ZDOORS File: Error","Could not load the specified doorsets.",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2798 }
2799 else if ( ret == 1 )
2800 {
2801 jwin_alert("ZDOORS File: Success!","Loaded the source doorsets!",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2802 saved=false;
2803 }
2804 else if ( ret == 2 )
2805 {
2806 jwin_alert("ZDOORS File: Issue:","Targets exceed doorset count!",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2807 saved=false;
2808 }
2809 pack_fclose(f);
2810 }
2811 }
2812 }
2813 }
2814
2815 int32_t gettilepagenumber(const char *prompt, int32_t initialval)
2816 {
2817 char buf[20];
2818 sprintf(buf,"%d",initialval);
2819 getnum_dlg[0].dp=(void *)prompt;
2820 getnum_dlg[0].dp2=get_zc_font(font_lfont);
2821 getnum_dlg[2].dp=buf;
2822
2823 large_dialog(getnum_dlg);
2824
2825 int32_t ret = do_zqdialog(getnum_dlg,2);
2826
2827 if(ret==3)
2828 return atoi(buf);
2829
2830 return -1;
2831 }
2832
2833 int32_t gethexnumber(const char *prompt,int32_t initialval)
2834 {
2835 cancelgetnum=true;
2836 char buf[20];
2837 sprintf(buf,"%X",initialval);
2838 getnum_dlg[0].dp=(void *)prompt;
2839 getnum_dlg[0].dp2=get_zc_font(font_lfont);
2840 getnum_dlg[2].dp=(void *)buf;
2841
2842 large_dialog(getnum_dlg);
2843
2844 int32_t ret=do_zqdialog(getnum_dlg,2);
2845
2846 if(ret!=0&&ret!=4)
2847 {
2848 cancelgetnum=false;
2849 }
2850
2851 if(ret==3)
2852 return zc_xtoi(buf);
2853
2854 return initialval;
2855 }
2856
2857 void update_combo_cycling()
2858 {
2859 Map.update_combo_cycling();
2860 }
2861
2862 void update_freeform_combos()
2863 {
2864 Map.update_freeform_combos();
2865 }
2866
2867 bool layers_valid(mapscr *tempscr)
2868 {
2869 for(int32_t i=0; i<6; i++)
2870 {
2871 if(tempscr->layermap[i]>map_count)
2872 {
2873 return false;
2874 }
2875 }
2876
2877 return true;
2878 }
2879
2880 void fix_layers(mapscr *tempscr, bool showwarning)
2881 {
2882 char buf[80]="layers have been changed: ";
2883
2884 for(int32_t i=0; i<6; i++)
2885 {
2886 if(tempscr->layermap[i]>map_count)
2887 {
2888 strcat(buf, "%d ");
2889 sprintf(buf, buf, i+1);
2890 tempscr->layermap[i]=0;
2891 }
2892 }
2893
2894 if(showwarning)
2895 {
2896 jwin_alert("Invalid layers detected",
2897 "One or more layers on this screen used",
2898 "maps that do not exist. The settings of these",
2899 buf, "O&K", NULL, 'o', 0, get_zc_font(font_lfont));
2900 }
2901 }
2902
2903 extern const char *colorlist(int32_t index, int32_t *list_size);
2904
2905 static char autobackup_str_buf[32];
2906 const char *autobackuplist(int32_t index, int32_t *list_size)
2907 {
2908 if(index>=0)
2909 {
2910 bound(index,0,10);
2911
2912 if(index==0)
2913 {
2914 sprintf(autobackup_str_buf,"Disabled");
2915 }
2916 else
2917 {
2918 sprintf(autobackup_str_buf,"%2d",index);
2919 }
2920
2921 return autobackup_str_buf;
2922 }
2923
2924 *list_size=11;
2925 return NULL;
2926 }
2927
2928 static char autosave_str_buf[32];
2929 const char *autosavelist(int32_t index, int32_t *list_size)
2930 {
2931 if(index>=0)
2932 {
2933 bound(index,0,10);
2934
2935 if(index==0)
2936 {
2937 sprintf(autosave_str_buf,"Disabled");
2938 }
2939 else
2940 {
2941 sprintf(autosave_str_buf,"%2d Minute%c",index,index>1?'s':0);
2942 }
2943
2944 return autosave_str_buf;
2945 }
2946
2947 *list_size=11;
2948 return NULL;
2949 }
2950
2951 const char *autosavelist2(int32_t index, int32_t *list_size)
2952 {
2953 if(index>=0)
2954 {
2955 bound(index,0,9);
2956 sprintf(autosave_str_buf,"%2d",index+1);
2957 return autosave_str_buf;
2958 }
2959
2960 *list_size=10;
2961 return NULL;
2962 }
2963
2964
2965 static int32_t options_1_list[] =
2966 {
2967 // dialog control number
2968 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, -1
2969 };
2970
2971 static int32_t options_2_list[] =
2972 {
2973 // dialog control number
2974 50, 51, -1
2975 };
2976
2977 static int32_t options_3_list[] =
2978 {
2979 // dialog control number
2980 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, -1
2981 };
2982 static int32_t options_4_list[] =
2983 {
2984 57, 58, 59, 60,
2985 -1
2986 };
2987
2988 static TABPANEL options_tabs[] =
2989 {
2990 // (text)
2991 { (char *)" 1 ", D_SELECTED, options_1_list, 0, NULL },
2992 { (char *)" 2 ", 0, options_2_list, 0, NULL },
2993 { (char *)" 3 ", 0, options_3_list, 0, NULL },
2994 { (char *)" 4 ", 0, options_4_list, 0, NULL },
2995 { NULL, 0, NULL, 0, NULL }
2996 };
2997
2998 12 static ListData autobackup_list(autobackuplist, &font);
2999 12 static ListData autosave_list(autosavelist, &font);
3000 12 static ListData autosave_list2(autosavelist2, &font);
3001 12 static ListData color_list(colorlist, &font);
3002 12 static ListData snapshotformat_list(snapshotformatlist, &font);
3003
3004 const char *dm_names[dm_max]=
3005 {
3006 "Normal",
3007 "Relational", // Removed.
3008 "Dungeon", // Removed.
3009 "Alias",
3010 "Pool",
3011 "Auto"
3012 };
3013
3014 void fix_drawing_mode_menu()
3015 {
3016 drawing_mode_menu.select_only_uid(draw_mode);
3017 }
3018
3019 int32_t onDrawingMode()
3020 {
3021 draw_mode=(draw_mode+1)%dm_max;
3022 int dm_relational = 1;
3023 if ((int)draw_mode == dm_relational)
3024 draw_mode += 2;
3025 fix_drawing_mode_menu();
3026 restore_mouse();
3027 return D_O_K;
3028 }
3029
3030 int32_t onDrawingModeNormal()
3031 {
3032 draw_mode=dm_normal;
3033 fix_drawing_mode_menu();
3034 restore_mouse();
3035 return D_O_K;
3036 }
3037
3038 int32_t onDrawingModeAlias()
3039 {
3040 if(draw_mode==dm_alias)
3041 {
3042 return onDrawingModeNormal();
3043 }
3044
3045 draw_mode=dm_alias;
3046 alias_cset_mod=0;
3047 fix_drawing_mode_menu();
3048 restore_mouse();
3049 return D_O_K;
3050 }
3051
3052 int32_t onDrawingModePool()
3053 {
3054 if(draw_mode==dm_cpool)
3055 {
3056 return onDrawingModeNormal();
3057 }
3058
3059 draw_mode=dm_cpool;
3060 fix_drawing_mode_menu();
3061 restore_mouse();
3062 return D_O_K;
3063 }
3064
3065 int32_t onDrawingModeAuto()
3066 {
3067 if (draw_mode == dm_auto)
3068 {
3069 return onDrawingModeNormal();
3070 }
3071
3072 draw_mode = dm_auto;
3073 fix_drawing_mode_menu();
3074 restore_mouse();
3075 return D_O_K;
3076 }
3077
3078 int32_t onReTemplate()
3079 {
3080 if(jwin_alert("Confirm Overwrite","Apply NES Dungeon template to","all screens on this map?",NULL,"&Yes","&No",'y','n',get_zc_font(font_lfont))==1)
3081 {
3082 Map.TemplateAll();
3083 refresh(rALL);
3084 }
3085
3086 return D_O_K;
3087 }
3088
3089 int32_t onUndo()
3090 {
3091 Map.UndoCommand();
3092 refresh(rALL);
3093 return D_O_K;
3094 }
3095
3096 int32_t onRedo()
3097 {
3098 Map.RedoCommand();
3099 refresh(rALL);
3100 return D_O_K;
3101 }
3102
3103 int32_t onCopy()
3104 {
3105 if(prv_mode)
3106 {
3107 Map.set_prvcmb(Map.get_prvcmb()==0?1:0);
3108 return D_O_K;
3109 }
3110
3111 int screen = active_visible_screen ? active_visible_screen->screen : Map.getCurrScr();
3112 Map.Copy(screen);
3113 return D_O_K;
3114 }
3115
3116 int32_t onPaste()
3117 {
3118 if(key[KEY_LSHIFT] || key[KEY_RSHIFT])
3119 {
3120 if(CHECK_CTRL_CMD)
3121 return onPasteAllToAll();
3122 else return onPasteAll();
3123 }
3124 else if(CHECK_CTRL_CMD)
3125 return onPasteToAll();
3126 else
3127 {
3128 int screen = active_visible_screen ? active_visible_screen->screen : Map.getCurrScr();
3129 Map.DoPasteScreenCommand(PasteCommandType::ScreenPartial, screen);
3130 }
3131 return D_O_K;
3132 }
3133
3134 int32_t onPasteAll()
3135 {
3136 int screen = active_visible_screen ? active_visible_screen->screen : Map.getCurrScr();
3137 Map.DoPasteScreenCommand(PasteCommandType::ScreenAll, screen);
3138 return D_O_K;
3139 }
3140
3141 int32_t onPasteToAll()
3142 {
3143 if(confirmBox("You are about to paste to all screens on the current map."))
3144 {
3145 Map.DoPasteScreenCommand(PasteCommandType::ScreenPartialToEveryScreen);
3146 }
3147 return D_O_K;
3148 }
3149
3150 int32_t onPasteAllToAll()
3151 {
3152 if(confirmBox("You are about to paste to all screens on the current map."))
3153 {
3154 Map.DoPasteScreenCommand(PasteCommandType::ScreenAllToEveryScreen);
3155 }
3156 return D_O_K;
3157 }
3158
3159 int32_t onPasteUnderCombo()
3160 {
3161 int screen = active_visible_screen ? active_visible_screen->screen : Map.getCurrScr();
3162 Map.DoPasteScreenCommand(PasteCommandType::ScreenUnderCombo, screen);
3163 return D_O_K;
3164 }
3165
3166 int32_t onPasteSecretCombos()
3167 {
3168 Map.DoPasteScreenCommand(PasteCommandType::ScreenSecretCombos);
3169 return D_O_K;
3170 }
3171
3172 int32_t onPasteFFCombos()
3173 {
3174 int screen = active_visible_screen ? active_visible_screen->screen : Map.getCurrScr();
3175 Map.DoPasteScreenCommand(PasteCommandType::ScreenFFCombos, screen);
3176 return D_O_K;
3177 }
3178
3179 int32_t onPasteWarps()
3180 {
3181 int screen = active_visible_screen ? active_visible_screen->screen : Map.getCurrScr();
3182 Map.DoPasteScreenCommand(PasteCommandType::ScreenWarps, screen);
3183 return D_O_K;
3184 }
3185
3186 int32_t onPasteScreenData()
3187 {
3188 int screen = active_visible_screen ? active_visible_screen->screen : Map.getCurrScr();
3189 Map.DoPasteScreenCommand(PasteCommandType::ScreenData, screen);
3190 return D_O_K;
3191 }
3192
3193 int32_t onPasteWarpLocations()
3194 {
3195 int screen = active_visible_screen ? active_visible_screen->screen : Map.getCurrScr();
3196 Map.DoPasteScreenCommand(PasteCommandType::ScreenWarpLocations, screen);
3197 return D_O_K;
3198 }
3199
3200 int32_t onPasteDoors()
3201 {
3202 int screen = active_visible_screen ? active_visible_screen->screen : Map.getCurrScr();
3203 Map.DoPasteScreenCommand(PasteCommandType::ScreenDoors, screen);
3204 return D_O_K;
3205 }
3206
3207 int32_t onPasteLayers()
3208 {
3209 int screen = active_visible_screen ? active_visible_screen->screen : Map.getCurrScr();
3210 Map.DoPasteScreenCommand(PasteCommandType::ScreenLayers, screen);
3211 return D_O_K;
3212 }
3213
3214 int32_t onPastePalette()
3215 {
3216 int screen = active_visible_screen ? active_visible_screen->screen : Map.getCurrScr();
3217 Map.DoPasteScreenCommand(PasteCommandType::ScreenPalette, screen);
3218 return D_O_K;
3219 }
3220
3221 int32_t onPasteRoom()
3222 {
3223 int screen = active_visible_screen ? active_visible_screen->screen : Map.getCurrScr();
3224 Map.DoPasteScreenCommand(PasteCommandType::ScreenRoom, screen);
3225 return D_O_K;
3226 }
3227
3228 int32_t onPasteGuy()
3229 {
3230 int screen = active_visible_screen ? active_visible_screen->screen : Map.getCurrScr();
3231 Map.DoPasteScreenCommand(PasteCommandType::ScreenGuy, screen);
3232 return D_O_K;
3233 }
3234
3235 int32_t onPasteEnemies()
3236 {
3237 int screen = active_visible_screen ? active_visible_screen->screen : Map.getCurrScr();
3238 Map.DoPasteScreenCommand(PasteCommandType::ScreenEnemies, screen);
3239 return D_O_K;
3240 }
3241
3242 int32_t onDelete()
3243 {
3244 restore_mouse();
3245
3246 int screen = active_visible_screen ? active_visible_screen->screen : Map.getCurrScr();
3247 mapscr* scr = active_visible_screen ? active_visible_screen->scr : Map.CurrScr();
3248 if(!(scr->valid&mVALID) || jwin_alert("Confirm Delete","Delete this screen?", NULL, NULL, "Yes", "Cancel", 'y', 27,get_zc_font(font_lfont)) == 1)
3249 {
3250 Map.DoClearScreenCommand(screen);
3251 }
3252
3253 saved=false;
3254 return D_O_K;
3255 }
3256
3257 int32_t onDeleteMap()
3258 {
3259 if(jwin_alert("Confirm Delete","Clear this entire map?", NULL, NULL, "Yes", "Cancel", 'y', 27,get_zc_font(font_lfont)) == 1)
3260 {
3261 Map.clearmap(false);
3262 refresh(rALL);
3263 saved=false;
3264 }
3265
3266 return D_O_K;
3267 }
3268
3269 int32_t onToggleDarkness()
3270 {
3271 Map.CurrScr()->flags^=4;
3272 refresh(rMAP+rMENU);
3273 saved=false;
3274 return D_O_K;
3275 }
3276
3277 int32_t onIncMap()
3278 {
3279 int32_t m=Map.getCurrMap();
3280 int32_t oldcolor=Map.getcolor();
3281 Map.setCurrMap(m+1>=map_count?0:m+1);
3282 // Map.setCurrScr(Map.getCurrScr()); //Needed to refresh the screen info. -Z ( 26th March, 2019 )
3283 Map.setlayertarget(); //Needed to refresh the screen info. -Z ( 26th March, 2019 )
3284
3285 int32_t newcolor=Map.getcolor();
3286
3287 if(newcolor!=oldcolor)
3288 {
3289 rebuild_trans_table();
3290 }
3291
3292 refresh(rALL);
3293 return D_O_K;
3294 }
3295
3296 int32_t onDecMap()
3297 {
3298 int32_t m=Map.getCurrMap();
3299 int32_t oldcolor=Map.getcolor();
3300 Map.setCurrMap((m-1<0)?map_count-1:zc_min(m-1,map_count-1));
3301 // Map.setCurrScr(Map.getCurrScr()); //Needed to refresh the screen info. -Z ( 26th March, 2019 )
3302 Map.setlayertarget(); //Needed to refresh the screen info. -Z ( 26th March, 2019 )
3303
3304 int32_t newcolor=Map.getcolor();
3305
3306 if(newcolor!=oldcolor)
3307 {
3308 rebuild_trans_table();
3309 }
3310
3311 refresh(rALL);
3312 return D_O_K;
3313 }
3314
3315
3316 int32_t onDefault_Pals()
3317 {
3318 if(jwin_alert("Confirm Reset","Reset all palette data?", NULL, NULL, "Yes", "Cancel", 'y', 27,get_zc_font(font_lfont)) == 1)
3319 {
3320 saved=false;
3321
3322 if(!init_colordata(true, &header, &QMisc))
3323 {
3324 jwin_alert("Error","Palette reset failed.",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
3325 }
3326
3327 refresh_pal();
3328 }
3329
3330 return D_O_K;
3331 }
3332
3333 int32_t onDefault_Combos()
3334 {
3335 if(jwin_alert("Confirm Reset","Reset combo data?", NULL, NULL, "Yes", "Cancel", 'y', 27,get_zc_font(font_lfont)) == 1)
3336 {
3337 saved=false;
3338
3339 if(!init_combos(true, &header))
3340 {
3341 jwin_alert("Error","Combo reset failed.",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
3342 }
3343
3344 refresh(rALL);
3345 }
3346
3347 return D_O_K;
3348 }
3349
3350 int32_t onDefault_Items()
3351 {
3352 if(jwin_alert("Confirm Reset","Reset all items?", NULL, NULL, "Yes", "Cancel", 'y', 27,get_zc_font(font_lfont)) == 1)
3353 {
3354 saved=false;
3355 reset_items(true, &header);
3356 }
3357
3358 return D_O_K;
3359 }
3360
3361 int32_t onDefault_Weapons()
3362 {
3363 if(jwin_alert("Confirm Reset","Reset weapon/misc. sprite data?", NULL, NULL, "Yes", "Cancel", 'y', 27,get_zc_font(font_lfont)) == 1)
3364 {
3365 saved=false;
3366 reset_wpns(true, &header);
3367 }
3368
3369 return D_O_K;
3370 }
3371
3372 int32_t onDefault_Guys()
3373 {
3374 if(jwin_alert("Confirm Reset","Reset all enemy/NPC data?", NULL, NULL, "Yes", "Cancel", 'y', 27,get_zc_font(font_lfont)) == 1)
3375 {
3376 saved=false;
3377 reset_guys();
3378 }
3379
3380 return D_O_K;
3381 }
3382
3383
3384 int32_t onDefault_Tiles()
3385 {
3386 if(jwin_alert("Confirm Reset","Reset all tiles?", NULL, NULL, "Yes", "Cancel", 'y', 27,get_zc_font(font_lfont)) == 1)
3387 {
3388 saved=false;
3389
3390 if(!init_tiles(true, &header))
3391 {
3392 jwin_alert("Error","Tile reset failed.",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
3393 }
3394
3395 refresh(rALL);
3396 }
3397
3398 return D_O_K;
3399 }
3400
3401 void change_sfx(SAMPLE *sfx1, SAMPLE *sfx2);
3402
3403 int32_t onDefault_SFX()
3404 {
3405 if(jwin_alert("Confirm Reset","Reset all sound effects?", NULL, NULL, "Yes", "Cancel", 'y', 27,get_zc_font(font_lfont)) == 1)
3406 {
3407 saved=false;
3408 SAMPLE *temp_sample;
3409
3410 for(int32_t i=1; i<WAV_COUNT; i++)
3411 {
3412 temp_sample = (SAMPLE *)sfxdata[zc_min(i,Z35)].dat;
3413 change_sfx(&customsfxdata[i], temp_sample);
3414 sprintf(sfx_string[i],"s%03d",i);
3415
3416 if(i<Z35)
3417 strcpy(sfx_string[i], old_sfx_string[i-1]);
3418 set_bit(customsfxflag, i<Z35?1:0, i-1);
3419 }
3420 }
3421
3422 return D_O_K;
3423 }
3424
3425
3426 int32_t onDefault_MapStyles()
3427 {
3428 if(jwin_alert("Confirm Reset","Reset all map styles?", NULL, NULL, "Yes", "Cancel", 'y', 27,get_zc_font(font_lfont)) == 1)
3429 {
3430 saved=false;
3431 reset_mapstyles(true, &QMisc);
3432 }
3433
3434 return D_O_K;
3435 }
3436
3437 int onScrollScreen(int dir, bool warp)
3438 {
3439 Map.scroll(dir,warp);
3440 return D_O_K;
3441 }
3442
3443 int32_t onComboColLeft()
3444 {
3445 if(draw_mode==dm_cpool||draw_mode==dm_auto)
3446 ;
3447 else if((First[current_combolist]>0)&&(draw_mode!=dm_alias))
3448 {
3449 First[current_combolist]-=1;
3450 clear_tooltip();
3451 refresh(rCOMBOS);
3452 }
3453 else if((combo_alistpos[current_comboalist]>0)&&(draw_mode==dm_alias))
3454 {
3455 combo_alistpos[current_comboalist]-=1;
3456 clear_tooltip();
3457 refresh(rCOMBOS);
3458 }
3459
3460 clear_keybuf();
3461 return D_O_K;
3462 }
3463
3464 int32_t onComboColRight()
3465 {
3466 auto& sqr = (draw_mode == dm_alias ? comboaliaslist[current_comboalist] : combolist[current_combolist]);
3467 if(draw_mode==dm_cpool||draw_mode==dm_auto)
3468 ;
3469 else if((First[current_combolist]<(MAXCOMBOS-(sqr.w*sqr.h)))&&(draw_mode!=dm_alias))
3470 {
3471 First[current_combolist]+=1;
3472 clear_tooltip();
3473 refresh(rCOMBOS);
3474 }
3475 else if((combo_alistpos[current_comboalist]<(MAXCOMBOALIASES-(sqr.w*sqr.h)))&&(draw_mode==dm_alias))
3476 {
3477 combo_alistpos[current_comboalist]+=1;
3478 clear_tooltip();
3479 refresh(rCOMBOS);
3480 }
3481
3482 clear_keybuf();
3483 return D_O_K;
3484 }
3485
3486 int32_t onComboColUp()
3487 {
3488 auto& sqr = (draw_mode == dm_alias ? comboaliaslist[current_comboalist] : combolist[current_combolist]);
3489 if(draw_mode==dm_cpool||draw_mode==dm_auto)
3490 ;
3491 else if((First[current_combolist]>0)&&(draw_mode!=dm_alias))
3492 {
3493 First[current_combolist]-=zc_min(First[current_combolist],sqr.w);
3494 clear_tooltip();
3495
3496 refresh(rCOMBOS);
3497 }
3498 else if((combo_alistpos[current_comboalist]>0)&&(draw_mode==dm_alias))
3499 {
3500 combo_alistpos[current_comboalist]-=zc_min(combo_alistpos[current_comboalist],sqr.w);
3501 clear_tooltip();
3502 refresh(rCOMBOS);
3503 }
3504
3505 clear_keybuf();
3506 return D_O_K;
3507 }
3508
3509 int32_t onComboColDown()
3510 {
3511 auto& sqr = (draw_mode == dm_alias ? comboaliaslist[current_comboalist] : combolist[current_combolist]);
3512
3513 if(draw_mode==dm_cpool||draw_mode==dm_auto)
3514 ;
3515 else if((First[current_combolist]<(MAXCOMBOS-(sqr.w*sqr.h)))&&(draw_mode!=dm_alias))
3516 {
3517 First[current_combolist]+=zc_min((MAXCOMBOS-sqr.w)-First[current_combolist],sqr.w);
3518 clear_tooltip();
3519 refresh(rCOMBOS);
3520 }
3521 else if((combo_alistpos[current_comboalist]<(MAXCOMBOALIASES-(comboaliaslist[0].w*comboaliaslist[0].h)))&&(draw_mode==dm_alias))
3522 {
3523 combo_alistpos[current_comboalist]+=zc_min((MAXCOMBOALIASES-sqr.w)-combo_alistpos[current_comboalist],sqr.w);
3524 clear_tooltip();
3525 refresh(rCOMBOS);
3526 }
3527
3528 clear_keybuf();
3529 return D_O_K;
3530 }
3531
3532 void scrollup(int j)
3533 {
3534 switch(draw_mode)
3535 {
3536 case dm_alias:
3537 {
3538 auto& sqr = comboaliaslist[j];
3539 if(combo_alistpos[j]>0)
3540 {
3541 if(CHECK_CTRL_CMD)
3542 {
3543 combo_alistpos[j]=0;
3544 clear_tooltip();
3545 }
3546 else
3547 {
3548 combo_alistpos[j]-=zc_min(combo_alistpos[j],(sqr.w*sqr.h));
3549 clear_tooltip();
3550 }
3551
3552 refresh(rCOMBOS);
3553 }
3554 break;
3555 }
3556 case dm_cpool:
3557 {
3558 auto& sqr = comboaliaslist[j];
3559 if(combo_pool_listpos[j]>0)
3560 {
3561 if(CHECK_CTRL_CMD)
3562 {
3563 combo_pool_listpos[j]=0;
3564 clear_tooltip();
3565 }
3566 else
3567 {
3568 combo_pool_listpos[j]-=zc_min(combo_pool_listpos[j],(sqr.w*sqr.h));
3569 clear_tooltip();
3570 }
3571
3572 refresh(rCOMBOS);
3573 }
3574 break;
3575 }
3576 case dm_auto:
3577 {
3578 auto& sqr = comboaliaslist[j];
3579 if (combo_auto_listpos[j] > 0)
3580 {
3581 if (CHECK_CTRL_CMD)
3582 {
3583 combo_auto_listpos[j] = 0;
3584 clear_tooltip();
3585 }
3586 else
3587 {
3588 combo_auto_listpos[j] -= zc_min(combo_auto_listpos[j], (sqr.w * sqr.h));
3589 clear_tooltip();
3590 }
3591
3592 refresh(rCOMBOS);
3593 }
3594 break;
3595 }
3596 default:
3597 {
3598 auto& sqr = combolist[j];
3599 if(First[j]>0)
3600 {
3601 if(CHECK_CTRL_CMD)
3602 {
3603 First[j]-=zc_min(First[j],256);
3604 clear_tooltip();
3605 }
3606 else
3607 {
3608 First[j]-=zc_min(First[j],(sqr.w*sqr.h));
3609 clear_tooltip();
3610 }
3611
3612 refresh(rCOMBOS);
3613 }
3614 break;
3615 }
3616 }
3617 }
3618 void scrolldown(int j)
3619 {
3620 switch(draw_mode)
3621 {
3622 case dm_alias:
3623 {
3624 auto& sqr = comboaliaslist[j];
3625 if(combo_alistpos[j]<(MAXCOMBOALIASES-(sqr.w*sqr.h)))
3626 {
3627 if(CHECK_CTRL_CMD)
3628 {
3629 combo_alistpos[j]=MAXCOMBOALIASES-(sqr.w*sqr.h);
3630 clear_tooltip();
3631 }
3632 else
3633 {
3634 combo_alistpos[j]=zc_min((MAXCOMBOALIASES-(sqr.w*sqr.h)),combo_alistpos[j]+(sqr.w*sqr.h));
3635 clear_tooltip();
3636 }
3637
3638 refresh(rCOMBOS);
3639 }
3640 break;
3641 }
3642 case dm_cpool:
3643 {
3644 auto& sqr = comboaliaslist[j];
3645 if(combo_pool_listpos[j]<(MAXCOMBOALIASES-(sqr.w*sqr.h)))
3646 {
3647 if(CHECK_CTRL_CMD)
3648 {
3649 combo_pool_listpos[j]=MAXCOMBOALIASES-(sqr.w*sqr.h);
3650 clear_tooltip();
3651 }
3652 else
3653 {
3654 combo_pool_listpos[j]=zc_min((MAXCOMBOALIASES-(sqr.w*sqr.h)),combo_pool_listpos[j]+(sqr.w*sqr.h));
3655 clear_tooltip();
3656 }
3657
3658 refresh(rCOMBOS);
3659 }
3660 break;
3661 }
3662 case dm_auto:
3663 {
3664 auto& sqr = comboaliaslist[j];
3665 if (combo_auto_listpos[j] < (MAXCOMBOALIASES - (sqr.w * sqr.h)))
3666 {
3667 if (CHECK_CTRL_CMD)
3668 {
3669 combo_auto_listpos[j] = MAXCOMBOALIASES - (sqr.w * sqr.h);
3670 clear_tooltip();
3671 }
3672 else
3673 {
3674 combo_auto_listpos[j] = zc_min((MAXCOMBOALIASES - (sqr.w * sqr.h)), combo_pool_listpos[j] + (sqr.w * sqr.h));
3675 clear_tooltip();
3676 }
3677
3678 refresh(rCOMBOS);
3679 }
3680 break;
3681 }
3682 default:
3683 {
3684 auto& sqr = combolist[j];
3685 if(First[j]<(MAXCOMBOS-(sqr.w*sqr.h)))
3686 {
3687 if(CHECK_CTRL_CMD)
3688 {
3689 First[j]=zc_min((MAXCOMBOS-sqr.w*sqr.h),First[j]+256);
3690 clear_tooltip();
3691 }
3692 else
3693 {
3694 First[j]=zc_min((MAXCOMBOS-(sqr.w*sqr.h)),First[j]+(sqr.w*sqr.h));
3695 clear_tooltip();
3696 }
3697
3698 refresh(rCOMBOS);
3699 }
3700 break;
3701 }
3702 }
3703 }
3704
3705 int32_t onPgUp()
3706 {
3707 switch(draw_mode)
3708 {
3709 case dm_alias:
3710 scrollup(current_comboalist);
3711 break;
3712 case dm_cpool:
3713 scrollup(current_cpoollist);
3714 break;
3715 case dm_auto:
3716 scrollup(current_cautolist);
3717 break;
3718 default:
3719 scrollup(current_combolist);
3720 break;
3721 }
3722 return D_O_K;
3723 }
3724
3725 int32_t onPgDn()
3726 {
3727 switch(draw_mode)
3728 {
3729 case dm_alias:
3730 scrolldown(current_comboalist);
3731 break;
3732 case dm_cpool:
3733 scrolldown(current_cpoollist);
3734 break;
3735 case dm_auto:
3736 scrolldown(current_cautolist);
3737 break;
3738 default:
3739 scrolldown(current_combolist);
3740 break;
3741 }
3742 return D_O_K;
3743 }
3744
3745 int32_t onIncreaseCSet()
3746 {
3747 if(draw_mode!=dm_alias)
3748 {
3749 CSet=wrap(CSet+1,0,13);
3750 refresh(rCOMBOS+rMENU+rCOMBO);
3751 }
3752 else
3753 {
3754 alias_cset_mod=wrap(alias_cset_mod+1,0,13);
3755 }
3756 return D_O_K;
3757 }
3758
3759 int32_t onDecreaseCSet()
3760 {
3761 if(draw_mode!=dm_alias)
3762 {
3763 CSet=wrap(CSet-1,0,13);
3764 refresh(rCOMBOS+rMENU+rCOMBO);
3765 }
3766 else
3767 {
3768 alias_cset_mod=wrap(alias_cset_mod-1,0,13);
3769 }
3770 return D_O_K;
3771 }
3772
3773 int32_t onGotoPage()
3774 {
3775 if (draw_mode==dm_alias)
3776 {
3777 static const int PER_PAGE = 260;
3778 if(optional<int> v = call_get_num("Scroll to Alias Page", 0, MAXCOMBOALIASES/PER_PAGE-1, 0))
3779 combo_alistpos[current_comboalist] = *v*PER_PAGE;
3780 }
3781 else if (draw_mode==dm_cpool)
3782 {
3783 static const int PER_PAGE = 260;
3784 if(optional<int> v = call_get_num("Scroll to Combo Pool Page", 0, MAXCOMBOPOOLS/PER_PAGE-1, 0))
3785 combo_pool_listpos[current_cpoollist] = *v*PER_PAGE;
3786 }
3787 else if (draw_mode == dm_auto)
3788 {
3789 static const int PER_PAGE = 260;
3790 if(optional<int> v = call_get_num("Scroll to Auto Combo Page", 0, MAXAUTOCOMBOS/PER_PAGE-1, 0))
3791 combo_auto_listpos[current_cautolist] = *v*PER_PAGE;
3792 }
3793 else
3794 {
3795 static const int PER_PAGE = 256;
3796 if(optional<int> v = call_get_num("Scroll to Combo Page", 0, MAXCOMBOS/PER_PAGE-1, 0))
3797 First[current_combolist] = *v*PER_PAGE;
3798 }
3799
3800 return D_O_K;
3801 }
3802
3803 static char track_number_str_buf[MIDI_TRACK_BUFFER_SIZE] = {0};
3804 const char *tracknumlist(int32_t index, int32_t *list_size)
3805 {
3806 //memset(track_number_str_buf,0,50);
3807 if(index>=0)
3808 {
3809 bound(index,0,255);
3810 std::string name = zcmusic_get_track_name(zcmusic, index);
3811 sprintf(track_number_str_buf,"%02d %s",index+1, name.c_str());
3812 return track_number_str_buf;
3813 }
3814
3815 *list_size=zcmusic_get_tracks(zcmusic);
3816 return NULL;
3817 }
3818
3819 12 static ListData tracknum_list(tracknumlist, &font);
3820
3821 static DIALOG change_track_dlg[] =
3822 {
3823 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
3824 12 { jwin_win_proc, 60-12, 40, 200-16, 72, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Select Track", NULL, NULL },
3825 12 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
3826 12 { jwin_droplist_proc, 72-12, 60+4, 161, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &tracknum_list, NULL, NULL },
3827 12 { jwin_button_proc, 70, 87, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
3828 12 { jwin_button_proc, 150, 87, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
3829 12 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
3830 };
3831 // return list_dlg[2].d1;
3832
3833 int32_t changeTrack()
3834 {
3835 restore_mouse();
3836 change_track_dlg[0].dp2=get_zc_font(font_lfont);
3837 change_track_dlg[2].d1=gme_track;
3838
3839 large_dialog(change_track_dlg);
3840
3841 if(do_zqdialog(change_track_dlg,2)==3)
3842 {
3843 gme_track=change_track_dlg[2].d1;
3844 zcmusic_change_track(zcmusic, gme_track);
3845 }
3846
3847 return D_O_K;
3848 }
3849
3850 void set_media_tunes()
3851 {
3852 media_menu.select_uid(MENUID_MEDIA_TUNES, true);
3853 media_menu.select_uid(MENUID_MEDIA_PLAYMUSIC, false);
3854 disable_hotkey(ZQKEY_AMBIENT_MUSIC, false);
3855 disable_hotkey(ZQKEY_PLAY_MUSIC, false);
3856
3857 media_menu.disable_uid(MENUID_MEDIA_CHANGETRACK, true);
3858 disable_hotkey(ZQKEY_CHANGE_TRACK, true);
3859 }
3860
3861 int32_t playMusic()
3862 {
3863 char *ext;
3864 bool ismidi=false;
3865 char allmusic_types[256];
3866 sprintf(allmusic_types, "%s;mid", zcmusic_types);
3867
3868 if(prompt_for_existing_file_compat("Load Music",(char*)allmusic_types,NULL,midipath,false))
3869 {
3870 strcpy(midipath,temppath);
3871
3872 ext=get_extension(midipath);
3873
3874 if(
3875 (stricmp(ext,"ogg")==0)||
3876 (stricmp(ext,"mp3")==0)||
3877 (stricmp(ext,"it")==0)||
3878 (stricmp(ext,"xm")==0)||
3879 (stricmp(ext,"s3m")==0)||
3880 (stricmp(ext,"mod")==0)||
3881 (stricmp(ext,"spc")==0)||
3882 (stricmp(ext,"gym")==0)||
3883 (stricmp(ext,"nsf")==0)||
3884 (stricmp(ext,"gbs")==0)||
3885 (stricmp(ext,"vgm")==0)
3886 )
3887 {
3888 ismidi=false;
3889 }
3890 else if((stricmp(ext,"mid")==0))
3891 {
3892 ismidi=true;
3893 }
3894 else
3895 {
3896 return D_O_K;
3897 }
3898
3899 zc_stop_midi();
3900
3901 if(zcmusic != NULL)
3902 {
3903 zcmusic_stop(zcmusic);
3904 zcmusic_unload_file(zcmusic);
3905 zcmusic = NULL;
3906 zcmixer->newtrack = NULL;
3907 }
3908
3909 if(ismidi)
3910 {
3911 packfile_password("");
3912 if((song=load_midi(midipath))!=NULL)
3913 {
3914 if(zc_play_midi(song,true)==0)
3915 {
3916 media_menu.select_uid(MENUID_MEDIA_TUNES, false);
3917 media_menu.select_uid(MENUID_MEDIA_PLAYMUSIC, true);
3918 disable_hotkey(ZQKEY_AMBIENT_MUSIC, false);
3919 disable_hotkey(ZQKEY_PLAY_MUSIC, false);
3920
3921 media_menu.disable_uid(MENUID_MEDIA_CHANGETRACK, true);
3922 disable_hotkey(ZQKEY_CHANGE_TRACK, true);
3923 }
3924 }
3925 }
3926 else
3927 {
3928 gme_track=0;
3929 zcmusic = (ZCMUSIC*)zcmusic_load_file(midipath);
3930
3931 if(zcmusic!=NULL)
3932 {
3933 media_menu.select_uid(MENUID_MEDIA_TUNES, false);
3934 media_menu.select_uid(MENUID_MEDIA_PLAYMUSIC, true);
3935 disable_hotkey(ZQKEY_AMBIENT_MUSIC, false);
3936 disable_hotkey(ZQKEY_PLAY_MUSIC, false);
3937
3938 bool distrack = zcmusic_get_tracks(zcmusic)<2;
3939 media_menu.disable_uid(MENUID_MEDIA_CHANGETRACK, distrack);
3940 disable_hotkey(ZQKEY_CHANGE_TRACK, distrack);
3941
3942 zcmusic_play(zcmusic, midi_volume);
3943 }
3944 }
3945 }
3946
3947 return D_O_K;
3948 }
3949
3950 int32_t playZCForever()
3951 {
3952 stopMusic();
3953
3954 zcmusic = zcmusic_load_file("assets/zc/ZC_Forever_HD.mp3");
3955 if (zcmusic)
3956 {
3957 zcmusic_play(zcmusic, midi_volume);
3958 set_media_tunes();
3959 }
3960 return D_O_K;
3961 }
3962
3963 // It took awhile to get these values right, so no meddlin'!
3964 int32_t playTune1()
3965 {
3966 return playTune(0);
3967 }
3968 int32_t playTune2()
3969 {
3970 return playTune(81);
3971 }
3972 int32_t playTune3()
3973 {
3974 return playTune(233);
3975 }
3976 int32_t playTune4()
3977 {
3978 return playTune(553);
3979 }
3980 int32_t playTune5()
3981 {
3982 return playTune(814);
3983 }
3984 int32_t playTune6()
3985 {
3986 return playTune(985);
3987 }
3988 int32_t playTune7()
3989 {
3990 return playTune(1153);
3991 }
3992 int32_t playTune8()
3993 {
3994 return playTune(1333);
3995 }
3996 int32_t playTune9()
3997 {
3998 return playTune(1556);
3999 }
4000 int32_t playTune10()
4001 {
4002 return playTune(1801);
4003 }
4004 int32_t playTune11()
4005 {
4006 return playTune(2069);
4007 }
4008 int32_t playTune12()
4009 {
4010 return playTune(2189);
4011 }
4012 int32_t playTune13()
4013 {
4014 return playTune(2569);
4015 }
4016 int32_t playTune14()
4017 {
4018 return playTune(2753);
4019 }
4020 int32_t playTune15()
4021 {
4022 return playTune(2856);
4023 }
4024 int32_t playTune16()
4025 {
4026 return playTune(3042);
4027 }
4028 int32_t playTune17()
4029 {
4030 return playTune(3125);
4031 }
4032 int32_t playTune18()
4033 {
4034 return playTune(3217);
4035 }
4036 int32_t playTune19()
4037 {
4038 return playTune(3296);
4039 }
4040
4041 int32_t playTune(int32_t pos)
4042 {
4043 zc_stop_midi();
4044
4045 if(zcmusic != NULL)
4046 {
4047 zcmusic_stop(zcmusic);
4048 zcmusic_unload_file(zcmusic);
4049 zcmusic = NULL;
4050 zcmixer->newtrack = NULL;
4051 }
4052
4053 if(zc_play_midi(asset_tunes_midi,true)==0)
4054 {
4055 zc_midi_seek(pos);
4056 set_media_tunes();
4057 }
4058
4059 return D_O_K;
4060 }
4061
4062 int32_t stopMusic()
4063 {
4064 zc_stop_midi();
4065
4066 if(zcmusic != NULL)
4067 {
4068 zcmusic_stop(zcmusic);
4069 zcmusic_unload_file(zcmusic);
4070 zcmusic = NULL;
4071 zcmixer->newtrack = NULL;
4072 }
4073
4074 media_menu.select_uid(MENUID_MEDIA_TUNES, false);
4075 media_menu.select_uid(MENUID_MEDIA_PLAYMUSIC, false);
4076 disable_hotkey(ZQKEY_AMBIENT_MUSIC, false);
4077 disable_hotkey(ZQKEY_PLAY_MUSIC, false);
4078
4079 media_menu.disable_uid(MENUID_MEDIA_CHANGETRACK, true);
4080 disable_hotkey(ZQKEY_CHANGE_TRACK, true);
4081 return D_O_K;
4082 }
4083
4084 static int32_t gamemisc1_list[] =
4085 {
4086 5,6,7,8,
4087 9,10,11,12,
4088
4089 37,38,39,40,
4090 41,42,43,44,
4091
4092 71,72,73,74,
4093 75,76,77,78,
4094
4095 -1
4096 };
4097
4098 static int32_t gamemisc2_list[] =
4099 {
4100 13,14,15,16,
4101 17,18,19,20,
4102
4103 45,46,47,48,
4104 49,50,51,52,
4105
4106 79,80,81,82,
4107 83,84,85,86,
4108
4109 -1
4110 };
4111
4112 static int32_t gamemisc3_list[] =
4113 {
4114 21,22,23,24,
4115 25,26,27,28,
4116
4117 53,54,55,56,
4118 57,58,59,60,
4119
4120 87,88,89,90,
4121 91,92,93,94,
4122
4123 -1
4124 };
4125
4126 static int32_t gamemisc4_list[] =
4127 {
4128 29,30,31,32,
4129 33,34,35,36,
4130
4131 61,62,63,64,
4132 65,66,67,68,
4133
4134 95,96,97,98,
4135 99,100,101,102,
4136
4137 -1
4138 };
4139
4140 static TABPANEL gamemisc_tabs[] =
4141 {
4142 // (text)
4143 { (char *)" Misc[0-7] ", D_SELECTED, gamemisc1_list, 0, NULL },
4144 { (char *)" Misc[8-15] ", 0, gamemisc2_list, 0, NULL },
4145 { (char *)" Misc[16-23] ", 0, gamemisc3_list, 0, NULL },
4146 { (char *)" Misc[24-31] ", 0, gamemisc4_list, 0, NULL },
4147 { NULL, 0, NULL, 0, NULL }
4148 };
4149
4150 //to do: Make string boxes larger, and split into two tabs.
4151 static DIALOG gamemiscarray_dlg[] =
4152 {
4153 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
4154
4155 { jwin_win_proc, 0, 10, 310, 224, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Game->Misc[]", NULL, NULL },
4156 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4157 { jwin_tab_proc, 3, 26, 304, 174, vc(14), vc(1), 0, 0, 1, 0, (void *) gamemisc_tabs, NULL, (void *)gamemiscarray_dlg },
4158 { d_dummy_proc, 240, 144, 40, 8, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
4159 { d_dummy_proc, 240, 144, 40, 8, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
4160
4161 //5
4162 { jwin_edit_proc, 8, 42, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4163 { jwin_edit_proc, 8, 42+20, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4164 { jwin_edit_proc, 8, 42+40, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4165 //8
4166 { jwin_edit_proc, 8, 42+60, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4167 { jwin_edit_proc, 8, 42+80, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4168 { jwin_edit_proc, 8, 42+100, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4169 { jwin_edit_proc, 8, 42+120, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4170 { jwin_edit_proc, 8, 42+140, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4171 //13
4172 { jwin_edit_proc, 8, 42, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4173 { jwin_edit_proc, 8, 42+20, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4174 { jwin_edit_proc, 8, 42+40, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4175 { jwin_edit_proc, 8, 42+60, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4176 { jwin_edit_proc, 8, 42+80, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4177 //18
4178 { jwin_edit_proc, 8, 42+100, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4179 { jwin_edit_proc, 8, 42+120, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4180 { jwin_edit_proc, 8, 42+140, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4181 { jwin_edit_proc, 8, 42, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4182 { jwin_edit_proc, 8, 42+20, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4183 //23
4184 { jwin_edit_proc, 8, 42+40, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4185 { jwin_edit_proc, 8, 42+60, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4186 { jwin_edit_proc, 8, 42+80, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4187 { jwin_edit_proc, 8, 42+100, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4188 { jwin_edit_proc, 8, 42+120, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4189 //28
4190 { jwin_edit_proc, 8, 42+140, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4191 { jwin_edit_proc, 8, 42, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4192 { jwin_edit_proc, 8, 42+20, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4193 { jwin_edit_proc, 8, 42+40, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4194 { jwin_edit_proc, 8, 42+60, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4195 //33
4196 { jwin_edit_proc, 8, 42+80, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4197 { jwin_edit_proc, 8, 42+100, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4198 { jwin_edit_proc, 8, 42+120, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4199 { jwin_edit_proc, 8, 42+140, 100-12, 16, vc(12), vc(1), 0, 0, 64, 0, NULL, NULL, NULL },
4200 //37
4201 { jwin_numedit_swap_zsint_proc, 96, 42, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4202 { jwin_numedit_swap_zsint_proc, 96, 42+20, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4203 //39
4204 { jwin_numedit_swap_zsint_proc, 96, 42+40, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4205 { jwin_numedit_swap_zsint_proc, 96, 42+60, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4206 { jwin_numedit_swap_zsint_proc, 96, 42+80, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4207 { jwin_numedit_swap_zsint_proc, 96, 42+100, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4208 { jwin_numedit_swap_zsint_proc, 96, 42+120, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4209 //44
4210 { jwin_numedit_swap_zsint_proc, 96, 42+140, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4211 { jwin_numedit_swap_zsint_proc, 96, 42, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4212 { jwin_numedit_swap_zsint_proc, 96, 42+20, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4213
4214 { jwin_numedit_swap_zsint_proc, 96, 42+40, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4215 { jwin_numedit_swap_zsint_proc, 96, 42+60, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4216 //49
4217 { jwin_numedit_swap_zsint_proc, 96, 42+80, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4218 { jwin_numedit_swap_zsint_proc, 96, 42+100, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4219 { jwin_numedit_swap_zsint_proc, 96, 42+120, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4220 { jwin_numedit_swap_zsint_proc, 96, 42+140, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4221 { jwin_numedit_swap_zsint_proc, 96, 42, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4222 //54
4223 { jwin_numedit_swap_zsint_proc, 96, 42+20, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4224 { jwin_numedit_swap_zsint_proc, 96, 42+40, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4225 { jwin_numedit_swap_zsint_proc, 96, 42+60, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4226 { jwin_numedit_swap_zsint_proc, 96, 42+80, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4227 { jwin_numedit_swap_zsint_proc, 96, 42+100, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4228 //59
4229 { jwin_numedit_swap_zsint_proc, 96, 42+120, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4230 { jwin_numedit_swap_zsint_proc, 96, 42+140, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4231 { jwin_numedit_swap_zsint_proc, 96, 42, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4232 { jwin_numedit_swap_zsint_proc, 96, 42+20, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4233 { jwin_numedit_swap_zsint_proc, 96, 42+40, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4234 //64
4235 { jwin_numedit_swap_zsint_proc, 96, 42+60, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4236 { jwin_numedit_swap_zsint_proc, 96, 42+80, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4237 { jwin_numedit_swap_zsint_proc, 96, 42+100, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4238 { jwin_numedit_swap_zsint_proc, 96, 42+120, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4239 { jwin_numedit_swap_zsint_proc, 96, 42+140, 60, 16, vc(12), vc(1), 0, 0, 12, 0, NULL, NULL, NULL },
4240 //69
4241 { jwin_button_proc, 70, 204, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
4242 { jwin_button_proc, 170, 204, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
4243
4244 //71
4245 { jwin_swapbtn_proc, 156, 42, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4246 { jwin_swapbtn_proc, 156, 62, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4247 { jwin_swapbtn_proc, 156, 82, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4248 { jwin_swapbtn_proc, 156, 102, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4249 { jwin_swapbtn_proc, 156, 122, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4250 { jwin_swapbtn_proc, 156, 142, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4251 { jwin_swapbtn_proc, 156, 162, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4252 { jwin_swapbtn_proc, 156, 182, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4253 //79
4254 { jwin_swapbtn_proc, 156, 42, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4255 { jwin_swapbtn_proc, 156, 62, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4256 { jwin_swapbtn_proc, 156, 82, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4257 { jwin_swapbtn_proc, 156, 102, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4258 { jwin_swapbtn_proc, 156, 122, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4259 { jwin_swapbtn_proc, 156, 142, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4260 { jwin_swapbtn_proc, 156, 162, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4261 { jwin_swapbtn_proc, 156, 182, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4262 //87
4263 { jwin_swapbtn_proc, 156, 42, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4264 { jwin_swapbtn_proc, 156, 62, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4265 { jwin_swapbtn_proc, 156, 82, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4266 { jwin_swapbtn_proc, 156, 102, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4267 { jwin_swapbtn_proc, 156, 122, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4268 { jwin_swapbtn_proc, 156, 142, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4269 { jwin_swapbtn_proc, 156, 162, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4270 { jwin_swapbtn_proc, 156, 182, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4271 //95
4272 { jwin_swapbtn_proc, 156, 42, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4273 { jwin_swapbtn_proc, 156, 62, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4274 { jwin_swapbtn_proc, 156, 82, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4275 { jwin_swapbtn_proc, 156, 102, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4276 { jwin_swapbtn_proc, 156, 122, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4277 { jwin_swapbtn_proc, 156, 142, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4278 { jwin_swapbtn_proc, 156, 162, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4279 { jwin_swapbtn_proc, 156, 182, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4280
4281 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
4282 };
4283
4284 // +----------+
4285 // | |
4286 // | View Pic |
4287 // | |
4288 // | |
4289 // | |
4290 // +----------+
4291
4292 BITMAP *pic=NULL;
4293 BITMAP *bmap=NULL;
4294 PALETTE picpal;
4295 PALETTE mappal;
4296 int32_t picx=0,picy=0,mapx=0,mapy=0,pblack,pwhite;
4297
4298 double picscale=1.0,mapscale=1.0;
4299 bool vp_showpal=true, vp_showsize=true, vp_center=true;
4300
4301 //INLINE int32_t pal_sum(RGB p) { return p.r + p.g + p.b; }
4302
4303 void get_bw(RGB *pal,int32_t &black,int32_t &white)
4304 {
4305 black=white=1;
4306
4307 for(int32_t i=1; i<256; i++)
4308 {
4309 if(pal_sum(pal[i])<pal_sum(pal[black]))
4310 black=i;
4311
4312 if(pal_sum(pal[i])>pal_sum(pal[white]))
4313 white=i;
4314 }
4315 }
4316
4317 void draw_bw_mouse(int32_t white, int32_t old_mouse, int32_t new_mouse)
4318 {
4319 blit(mouse_bmp[old_mouse][0],mouse_bmp[new_mouse][0],0,0,0,0,16,16);
4320
4321 for(int32_t y=0; y<16; y++)
4322 {
4323 for(int32_t x=0; x<16; x++)
4324 {
4325 if(getpixel(mouse_bmp[new_mouse][0],x,y)!=0)
4326 {
4327 putpixel(mouse_bmp[new_mouse][0],x,y,white);
4328 }
4329 }
4330 }
4331 }
4332
4333 int32_t load_the_pic(BITMAP **dst, PALETTE dstpal)
4334 {
4335 PALETTE temppal;
4336
4337 for(int32_t i=0; i<256; i++)
4338 {
4339 temppal[i]=dstpal[i];
4340 dstpal[i]=RAMpal[i];
4341 }
4342
4343 // set up the new palette
4344 for(int32_t i=0; i<64; i++)
4345 {
4346 dstpal[i].r = i;
4347 dstpal[i].g = i;
4348 dstpal[i].b = i;
4349 }
4350
4351 zc_set_palette(dstpal);
4352
4353 BITMAP *graypic = create_bitmap_ex(8,screen->w,screen->h);
4354 int32_t _w = screen->w-1;
4355 int32_t _h = screen->h-1;
4356
4357 // gray scale the current frame
4358 for(int32_t y=0; y<_h; y++)
4359 {
4360 for(int32_t x=0; x<_w; x++)
4361 {
4362 int32_t c = screen->line[y][x];
4363 int32_t gray = zc_min((temppal[c].r*42 + temppal[c].g*75 + temppal[c].b*14) >> 7, 63);
4364 graypic->line[y][x] = gray;
4365 }
4366 }
4367
4368 blit(graypic,screen,0,0,0,0,screen->w,screen->h);
4369 destroy_bitmap(graypic);
4370 #ifdef __GNUC__
4371 #pragma GCC diagnostic ignored "-Wformat-overflow"
4372 #endif
4373 char extbuf[2][80];
4374 memset(extbuf[0],0,80);
4375 memset(extbuf[1],0,80);
4376 sprintf(extbuf[0], "View Image (%s", snapshotformat_str[0][1]);
4377 strcpy(extbuf[1], snapshotformat_str[0][1]);
4378
4379 for(int32_t i=1; i<ssfmtMAX; ++i)
4380 {
4381 sprintf(extbuf[0], "%s, %s", extbuf[0], snapshotformat_str[i][1]);
4382 sprintf(extbuf[1], "%s;%s", extbuf[1], snapshotformat_str[i][1]);
4383 }
4384
4385 sprintf(extbuf[0], "%s)", extbuf[0]);
4386 #ifdef __GNUC__
4387 #pragma GCC diagnostic pop
4388 #endif
4389
4390 int32_t gotit = prompt_for_existing_file_compat(extbuf[0],extbuf[1],NULL,imagepath,true);
4391
4392 if(!gotit)
4393 {
4394 zc_set_palette(temppal);
4395 get_palette(dstpal);
4396 return 1;
4397 }
4398
4399 strcpy(imagepath,temppath);
4400
4401 if(*dst)
4402 {
4403 destroy_bitmap(*dst);
4404 }
4405
4406 for(int32_t i=0; i<256; i++)
4407 {
4408 dstpal[i].r = 0;
4409 dstpal[i].g = 0;
4410 dstpal[i].b = 0;
4411 }
4412
4413 *dst = load_bitmap(imagepath,picpal);
4414
4415 if(!*dst)
4416 {
4417 jwin_alert("Error","Error loading image:",imagepath,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
4418 return 2;
4419 }
4420
4421 // get_bw(picpal,pblack,pwhite);
4422 // draw_bw_mouse(pwhite);
4423 // gui_bg_color = pblack;
4424 // gui_fg_color = pwhite;
4425
4426 if(vp_center)
4427 {
4428 picx=picy=0;
4429 }
4430 else
4431 {
4432 picx=(*dst)->w-zq_screen_w;
4433 picy=(*dst)->h-zq_screen_h;
4434 }
4435
4436 return 0;
4437 }
4438 int load_the_pic_new(BITMAP **dst, PALETTE dstpal)
4439 {
4440 #ifdef __GNUC__
4441 #pragma GCC diagnostic ignored "-Wformat-overflow"
4442 #endif
4443 char extbuf[2][80];
4444 memset(extbuf[0],0,80);
4445 memset(extbuf[1],0,80);
4446 sprintf(extbuf[0], "View Image (%s", snapshotformat_str[0][1]);
4447 strcpy(extbuf[1], snapshotformat_str[0][1]);
4448
4449 for(int32_t i=1; i<ssfmtMAX; ++i)
4450 {
4451 sprintf(extbuf[0], "%s, %s", extbuf[0], snapshotformat_str[i][1]);
4452 sprintf(extbuf[1], "%s;%s", extbuf[1], snapshotformat_str[i][1]);
4453 }
4454
4455 sprintf(extbuf[0], "%s)", extbuf[0]);
4456 #ifdef __GNUC__
4457 #pragma GCC diagnostic pop
4458 #endif
4459
4460 int32_t gotit = prompt_for_existing_file_compat(extbuf[0],extbuf[1],NULL,imagepath,true);
4461
4462 if(!gotit)
4463 return 1;
4464
4465 strcpy(imagepath,temppath);
4466
4467 if(*dst)
4468 destroy_bitmap(*dst);
4469
4470 for(int32_t i=0; i<256; i++)
4471 {
4472 dstpal[i].r = 0;
4473 dstpal[i].g = 0;
4474 dstpal[i].b = 0;
4475 }
4476
4477 *dst = load_bitmap(imagepath,dstpal);
4478
4479 if(!*dst)
4480 {
4481 jwin_alert("Error","Error loading image:",imagepath,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
4482 return 2;
4483 }
4484
4485 if(vp_center)
4486 {
4487 picx=picy=0;
4488 }
4489 else
4490 {
4491 picx=(*dst)->w-zq_screen_w;
4492 picy=(*dst)->h-zq_screen_h;
4493 }
4494
4495 return 0;
4496 }
4497
4498 int32_t saveMapAsImage(ALLEGRO_BITMAP* bitmap)
4499 {
4500 char buf[200];
4501 int32_t num=0;
4502
4503 do
4504 {
4505 snprintf(buf, 200, "%szquest_map%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
4506 buf[199]='\0';
4507 }
4508 while(num<99999 && exists(buf));
4509
4510 if (!al_save_bitmap(buf, bitmap))
4511 InfoDialog("Error", "Failed to save map image").show();
4512
4513 return D_O_K;
4514 }
4515
4516 int32_t onViewPic()
4517 {
4518 return launchPicViewer(&pic,picpal,&picx,&picy,&picscale,false);
4519 }
4520
4521
4522 class MapViewRTI : public RenderTreeItem
4523 {
4524 public:
4525
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
12 MapViewRTI(): RenderTreeItem("map_view")
4526 12 {
4527 12 }
4528
4529 int bw, bh, sw, sh, flags;
4530
4531 private:
4532 void render(bool bitmap_resized)
4533 {
4534 MapCursor previous_cursor = Map.getCursor();
4535 Map.setViewSize(1);
4536
4537 BITMAP* bmap4_single = create_bitmap_ex(8,256,176);
4538 set_bitmap_create_flags(true);
4539 ALLEGRO_BITMAP* bmap5_single = al_create_bitmap(256,176);
4540 for(int32_t y=0; y<8; y++)
4541 {
4542 for(int32_t x=0; x<16; x++)
4543 {
4544 clear_bitmap(bmap4_single);
4545 Map.setCurrScr(y*16+x);
4546 Map.draw(bmap4_single, 0, 0, flags, -1, y*16+x, -1);
4547 stretch_blit(bmap4_single, bmap4_single, 0, 0, 0, 0, 256, 176, 256, 176);
4548 all_render_a5_bitmap(bmap4_single, bmap5_single);
4549 al_draw_scaled_bitmap(bmap5_single, 0, 0, 256, 176, sw * x, sh * y, sw, sh, 0);
4550 }
4551 }
4552
4553 Map.setCursor(previous_cursor);
4554 destroy_bitmap(bmap4_single);
4555 al_destroy_bitmap(bmap5_single);
4556 }
4557 };
4558 12 static MapViewRTI rti_map_view;
4559
4560 int32_t launchPicViewer(BITMAP **pictoview, PALETTE pal, int32_t *px2, int32_t *py2, double *scale2, bool isviewingmap, bool skipmenu)
4561 {
4562 restore_mouse();
4563 BITMAP *buf;
4564 bool done=false, redraw=true;
4565
4566 popup_zqdialog_start();
4567
4568 // Always call load_the_map() when viewing the map.
4569 if((!*pictoview || isviewingmap) && (isviewingmap ? load_the_map(skipmenu) : load_the_pic(pictoview,pal)))
4570 {
4571 zc_set_palette(RAMpal);
4572 popup_zqdialog_end();
4573 close_the_map();
4574 return D_O_K;
4575 }
4576
4577 get_bw(pal,pblack,pwhite);
4578
4579 int32_t oldfgcolor = gui_fg_color;
4580 int32_t oldbgcolor = gui_bg_color;
4581
4582 buf = create_bitmap_ex(8,zq_screen_w,zq_screen_h);
4583
4584 if(!buf)
4585 {
4586 jwin_alert("Error","Error creating temp bitmap",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
4587 popup_zqdialog_end();
4588 close_the_map();
4589 return D_O_K;
4590 }
4591
4592 static LegacyBitmapRTI viewer_overlay_rti("viewer_overlay");
4593 viewer_overlay_rti.set_size(buf->w, buf->h);
4594 viewer_overlay_rti.a4_bitmap = buf;
4595 viewer_overlay_rti.transparency_index = 15;
4596 get_root_rti()->add_child(&viewer_overlay_rti);
4597
4598 zc_set_palette(pal);
4599
4600 if(isviewingmap)
4601 {
4602 set_center_root_rti(false);
4603
4604 int sw = rti_map_view.width / 16;
4605 int sh = rti_map_view.height / 8;
4606 int screen = Map.getCurrScr();
4607 if (screen >= 0x00 && screen <= 0x7F)
4608 {
4609 auto root_transform = get_root_rti()->get_transform();
4610 int dw = al_get_display_width(all_get_display()) / root_transform.xscale;
4611 int dh = al_get_display_height(all_get_display()) / root_transform.yscale;
4612 mapx = (-(screen % 16) * sw - sw/2 + dw/2);
4613 mapy = (-(screen / 16) * sh - sh/2 + dh/2);
4614 }
4615 }
4616
4617 do
4618 {
4619 int w, h;
4620 if (isviewingmap)
4621 {
4622 w = rti_map_view.width;
4623 h = rti_map_view.height;
4624 }
4625 else
4626 {
4627 w = (*pictoview)->w;
4628 h = (*pictoview)->h;
4629 }
4630
4631 if (isviewingmap)
4632 {
4633 float scale = *scale2;
4634 auto root_transform = get_root_rti()->get_transform();
4635 int dw = al_get_display_width(all_get_display()) / root_transform.xscale;
4636 int dh = al_get_display_height(all_get_display()) / root_transform.yscale;
4637 mapx = std::max(mapx, (int)(-w*scale + dw));
4638 mapy = std::max(mapy, (int)(-h*scale + dh));
4639 mapx = std::min(mapx, 0);
4640 mapy = std::min(mapy, 0);
4641 rti_map_view.set_transform({mapx, mapy, scale, scale});
4642 }
4643
4644 if(redraw)
4645 {
4646 clear_to_color(buf,15);
4647
4648 if (!isviewingmap)
4649 stretch_blit(*pictoview, buf, 0, 0, w, h,
4650 int32_t(zq_screen_w + (*px2 - w) * *scale2) / 2, int32_t(zq_screen_h + (*py2 - h) * *scale2) / 2,
4651 int32_t(w * *scale2), int32_t(h * *scale2));
4652
4653 if(vp_showpal)
4654 for(int32_t i=0; i<256; i++)
4655 rectfill(buf,((i&15)<<2)+zq_screen_w-64,((i>>4)<<2)+zq_screen_h-64,((i&15)<<2)+zq_screen_w-64+3,((i>>4)<<2)+zq_screen_h-64+3,i);
4656
4657 if(vp_showsize)
4658 {
4659 textprintf_ex(buf,font,0,zq_screen_h-8,pwhite,pblack,"%dx%d %.2f%%",w,h,*scale2*100.0);
4660 }
4661
4662 if (!isviewingmap)
4663 blit(buf,screen,0,0,0,0,zq_screen_w,zq_screen_h);
4664 redraw=false;
4665 }
4666
4667 custom_vsync();
4668
4669 int32_t step = 16;
4670
4671 if(*scale2 < 1.0)
4672 step = int32_t(4.0/ *scale2);
4673
4674 if(key[KEY_LSHIFT] || key[KEY_RSHIFT])
4675 step <<= 2;
4676
4677 if(CHECK_CTRL_CMD)
4678 step >>= 1;
4679
4680 if(key[KEY_UP])
4681 {
4682 *py2+=step;
4683 redraw=true;
4684 }
4685
4686 if(key[KEY_DOWN])
4687 {
4688 *py2-=step;
4689 redraw=true;
4690 }
4691
4692 if(key[KEY_LEFT])
4693 {
4694 *px2+=step;
4695 redraw=true;
4696 }
4697
4698 if(key[KEY_RIGHT])
4699 {
4700 *px2-=step;
4701 redraw=true;
4702 }
4703
4704 if(keypressed() && !redraw)
4705 switch(readkey()>>8)
4706 {
4707 case KEY_PGUP:
4708 *scale2*=0.95;
4709
4710 if(*scale2<0.1) *scale2=0.1;
4711
4712 redraw=true;
4713 break;
4714
4715 case KEY_PGDN:
4716 *scale2/=0.95;
4717
4718 if(*scale2>5.0) *scale2=5.0;
4719
4720 redraw=true;
4721 break;
4722
4723 case KEY_HOME:
4724 *scale2/=2.0;
4725
4726 if(*scale2<0.1) *scale2=0.1;
4727
4728 redraw=true;
4729 break;
4730
4731 case KEY_END:
4732 *scale2*=2.0;
4733
4734 if(*scale2>5.0) *scale2=5.0;
4735
4736 redraw=true;
4737 break;
4738
4739 case KEY_TILDE:
4740 *scale2=0.5;
4741 redraw=true;
4742 break;
4743
4744 case KEY_Z:
4745 *px2=w-zq_screen_w;
4746 *py2=h-zq_screen_h;
4747 vp_center=false;
4748 redraw=true;
4749 break;
4750
4751 case KEY_1:
4752 *scale2=1.0;
4753 redraw=true;
4754 break;
4755
4756 case KEY_2:
4757 *scale2=2.0;
4758 redraw=true;
4759 break;
4760
4761 case KEY_3:
4762 *scale2=3.0;
4763 redraw=true;
4764 break;
4765
4766 case KEY_4:
4767 *scale2=4.0;
4768 redraw=true;
4769 break;
4770
4771 case KEY_5:
4772 *scale2=5.0;
4773 redraw=true;
4774 break;
4775
4776 case KEY_C:
4777 *px2=*py2=0;
4778 redraw=vp_center=true;
4779 break;
4780
4781 case KEY_S:
4782 vp_showsize = !vp_showsize;
4783 redraw=true;
4784 break;
4785
4786 case KEY_D:
4787 vp_showpal = !vp_showpal;
4788 redraw=true;
4789 break;
4790
4791 case KEY_P:
4792 if(isviewingmap) break;
4793
4794 case KEY_ESC:
4795 done=true;
4796 break;
4797
4798 case KEY_SPACE:
4799 close_the_map();
4800 // TODO: why is `load_the_map` rendering a black dialog?
4801 if(isviewingmap ? load_the_map(skipmenu) : load_the_pic(pictoview,pal)==2)
4802 {
4803 done=true;
4804 }
4805 else
4806 {
4807 redraw=true;
4808 gui_bg_color = pblack;
4809 gui_fg_color = pwhite;
4810 *scale2=1.0;
4811 zc_set_palette(pal);
4812 }
4813
4814 get_bw(pal,pblack,pwhite);
4815 break;
4816 }
4817 }
4818 while(!done);
4819
4820 destroy_bitmap(buf);
4821 zc_set_palette(RAMpal);
4822 gui_fg_color = oldfgcolor;
4823 gui_bg_color = oldbgcolor;
4824
4825 popup_zqdialog_end();
4826 position_mouse_z(0);
4827 viewer_overlay_rti.remove();
4828 set_center_root_rti(true);
4829 close_the_map();
4830 return D_O_K;
4831 }
4832
4833 static DIALOG loadmap_dlg[] =
4834 {
4835 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
4836 { jwin_win_proc, 0, 0, 225, 143, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "View Map", NULL, NULL },
4837 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
4838 { jwin_text_proc, 32, 26, 96, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Resolution", NULL, NULL },
4839 // 3
4840 { jwin_radio_proc, 16, 36, 97, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "1/4 - 1024x352", NULL, NULL },
4841 { jwin_radio_proc, 16, 46, 97, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "1/2 - 2048x704", NULL, NULL },
4842 { jwin_radio_proc, 16, 56, 97, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "Full - 4096x1408", NULL, NULL },
4843 { jwin_text_proc, 144, 26, 97, 9, vc(11), vc(1), 0, 0, 0, 0, (void *) "Options", NULL, NULL },
4844 // 7
4845 { jwin_check_proc, 144, 36, 97, 9, vc(14), vc(1), 0, 0, 1, 0, (void *) "Solidity", NULL, NULL },
4846 { jwin_check_proc, 144, 46, 97, 9, vc(14), vc(1), 0, 0, 1, 0, (void *) "Flags", NULL, NULL },
4847 { jwin_check_proc, 144, 56, 97, 9, vc(14), vc(1), 0, 0, 1, 0, (void *) "Dark", NULL, NULL },
4848 { jwin_check_proc, 144, 66, 97, 9, vc(14), vc(1), 0, 0, 1, 0, (void *) "Items", NULL, NULL },
4849 // 11
4850 { jwin_button_proc, 42, 110, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
4851 { jwin_button_proc, 122, 110, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
4852 { jwin_check_proc, 16, 88, 97, 9, vc(14), vc(1), 0, 0, 1, 0, (void *) "Save to Image", NULL, NULL },
4853 // 14
4854 { jwin_radio_proc, 16, 66, 97, 9, vc(14), vc(1), 0, 0, 0, 0, (void*)"2x - 8192x2816", NULL, NULL },
4855 { jwin_radio_proc, 16, 76, 97, 9, vc(14), vc(1), 0, 0, 0, 0, (void*)"4x - 16384x5632", NULL, NULL },
4856 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
4857 };
4858
4859 int32_t load_the_map(bool skipmenu)
4860 {
4861 static int32_t res = 0;
4862 static int32_t flags = cDEBUG;
4863
4864 loadmap_dlg[0].dp2 = get_zc_font(font_lfont);
4865 loadmap_dlg[3].flags = (res==2) ? D_SELECTED : 0;
4866 loadmap_dlg[4].flags = (res==1) ? D_SELECTED : 0;
4867 loadmap_dlg[5].flags = (res==0) ? D_SELECTED : 0;
4868 loadmap_dlg[7].flags = (flags&cWALK) ? D_SELECTED : 0;
4869 loadmap_dlg[8].flags = (flags&cFLAGS) ? D_SELECTED : 0;
4870 loadmap_dlg[9].flags = (flags&cNODARK) ? 0 : D_SELECTED;
4871 loadmap_dlg[10].flags = (flags&cNOITEM) ? 0 : D_SELECTED;
4872 loadmap_dlg[13].flags = 0;
4873 loadmap_dlg[14].flags = (res==3) ? D_SELECTED : 0;
4874 loadmap_dlg[15].flags = (res==4) ? D_SELECTED : 0;
4875
4876 if(!skipmenu)
4877 {
4878 large_dialog(loadmap_dlg);
4879
4880 if (do_zqdialog(loadmap_dlg, 11) != 11)
4881 {
4882 return 1;
4883 }
4884
4885 flags = cDEBUG;
4886
4887 if(loadmap_dlg[3].flags&D_SELECTED) res=2;
4888
4889 if(loadmap_dlg[4].flags&D_SELECTED) res=1;
4890
4891 if(loadmap_dlg[5].flags&D_SELECTED) res=0;
4892
4893 if(loadmap_dlg[7].flags&D_SELECTED) flags|=cWALK;
4894
4895 if(loadmap_dlg[8].flags&D_SELECTED) flags|=cFLAGS;
4896
4897 if(!(loadmap_dlg[9].flags&D_SELECTED)) flags|=cNODARK;
4898
4899 if(!(loadmap_dlg[10].flags&D_SELECTED)) flags|=cNOITEM;
4900
4901 if(loadmap_dlg[14].flags&D_SELECTED) res=3;
4902
4903 if(loadmap_dlg[15].flags&D_SELECTED) res=4;
4904 }
4905
4906 int32_t bw = (256*16)>>res;
4907 int32_t bh = (176*8)>>res;
4908 int32_t sw = 256>>res;
4909 int32_t sh = 176>>res;
4910 if(res>2)
4911 {
4912 bw = (256*16)<<(res-2);
4913 bh = (176*8)<<(res-2);
4914 sw = 256<<(res-2);
4915 sh = 176<<(res-2);
4916 }
4917
4918 rti_map_view.flags = flags;
4919 rti_map_view.bw = bw;
4920 rti_map_view.bh = bh;
4921 rti_map_view.sw = sw;
4922 rti_map_view.sh = sh;
4923 rti_map_view.set_size(bw, bh);
4924 rti_map_view.dirty = true;
4925 get_root_rti()->add_child(&rti_map_view);
4926 render_zq();
4927
4928 vp_showpal = false;
4929 get_bw(picpal,pblack,pwhite);
4930 mapx = mapy = 0;
4931 mapscale = 1;
4932 imagepath[0] = 0;
4933
4934 if(loadmap_dlg[13].flags & D_SELECTED) saveMapAsImage(rti_map_view.bitmap);
4935
4936 memcpy(mappal,RAMpal,sizeof(RAMpal));
4937
4938 return 0;
4939 }
4940
4941 void close_the_map()
4942 {
4943 rti_map_view.remove();
4944 }
4945
4946 int32_t onViewMap()
4947 {
4948 return onViewMapEx(false);
4949 }
4950 int32_t onViewMapEx(bool skipmenu)
4951 {
4952 int32_t temp_aligns=ShowMisalignments;
4953 ShowMisalignments=0;
4954 //if(load_the_map()==0)
4955 //{
4956 launchPicViewer(&bmap,mappal,&mapx, &mapy, &mapscale,true,skipmenu);
4957 //}
4958 ShowMisalignments=temp_aligns;
4959 return D_O_K;
4960 }
4961
4962 static const char *mazedirstr[4] = {"North","South","West","East"};
4963 char _pathstr[40]="North,North,North,North";
4964
4965 char *pathstr(byte path[])
4966 {
4967 sprintf(_pathstr,"%s,%s,%s,%s",mazedirstr[path[0]],mazedirstr[path[1]],
4968 mazedirstr[path[2]],mazedirstr[path[3]]);
4969 return _pathstr;
4970 }
4971
4972 char _ticksstr[32]="99.99 seconds";
4973
4974 char *ticksstr(int32_t tics)
4975 {
4976 int32_t mins=tics/(60*60);
4977 tics=tics-(mins*60*60);
4978 int32_t secs=tics/60;
4979 tics=tics-(secs*60);
4980 tics=tics*100/60;
4981
4982 if(mins>0)
4983 {
4984 sprintf(_ticksstr,"%d:%02d.%02d",mins, secs, tics);
4985 }
4986 else
4987 {
4988 sprintf(_ticksstr,"%d.%02d seconds",secs, tics);
4989 }
4990
4991 return _ticksstr;
4992 }
4993
4994 ZC_FORMAT_PRINTF(7, 8)
4995 void textprintf_disabled(BITMAP *bmp, AL_CONST FONT *f, int32_t x, int32_t y, int32_t color_hl, int32_t color_sh, AL_CONST char *format, ...)
4996 {
4997 char buf[512];
4998 va_list ap;
4999 ASSERT(bmp);
5000 ASSERT(f);
5001 ASSERT(format);
5002
5003 va_start(ap, format);
5004 uvszprintf(buf, sizeof(buf), format, ap);
5005 va_end(ap);
5006
5007
5008 textout_ex(bmp, f, buf, x+1, y+1, color_hl, -1);
5009
5010 textout_ex(bmp, f, buf, x, y, color_sh, -1);
5011 }
5012
5013 ZC_FORMAT_PRINTF(7, 8)
5014 void textprintf_centre_disabled(BITMAP *bmp, AL_CONST FONT *f, int32_t x, int32_t y, int32_t color_hl, int32_t color_sh, AL_CONST char *format, ...)
5015 {
5016 char buf[512];
5017 va_list ap;
5018 ASSERT(bmp);
5019 ASSERT(f);
5020 ASSERT(format);
5021
5022 va_start(ap, format);
5023 uvszprintf(buf, sizeof(buf), format, ap);
5024 va_end(ap);
5025
5026 textout_centre_ex(bmp, f, buf, x+1, y+1, color_hl, -1);
5027 textout_centre_ex(bmp, f, buf, x, y, color_sh, -1);
5028 }
5029
5030 void draw_sqr_frame(size_and_pos const& sqr)
5031 {
5032 jwin_draw_frame(menu1,sqr.x,sqr.y,sqr.tw(),sqr.th(),FR_DEEP);
5033 }
5034 void draw_sqr_icon(size_and_pos const& sqr, BITMAP* icon)
5035 {
5036 stretch_blit(icon, menu1, 0, 0, 16, 16, sqr.x+2, sqr.y+2, sqr.tw()-4, sqr.th()-4);
5037 }
5038 void draw_sqr_nums(size_and_pos const& sqr, FONT* f, bool center, int num)
5039 {
5040 if(center)
5041 textprintf_centre_ex(menu1,f,sqr.x+txtoffs_single.x,sqr.y+txtoffs_single.y,jwin_pal[jcBOXFG],-1,"%d",num);
5042 else
5043 textprintf_ex(menu1,f,sqr.x+txtoffs_single.x,sqr.y+txtoffs_single.y,jwin_pal[jcBOXFG],-1,"%d",num);
5044 }
5045 void draw_sqr_nums(size_and_pos const& sqr, FONT* f, bool center, int num1, int num2)
5046 {
5047 if(center)
5048 {
5049 textprintf_centre_ex(menu1,f,sqr.x+txtoffs_double_1.x,sqr.y+txtoffs_double_1.y,jwin_pal[jcBOXFG],-1,"%d",num1);
5050 textprintf_centre_ex(menu1,f,sqr.x+txtoffs_double_2.x,sqr.y+txtoffs_double_2.y,jwin_pal[jcBOXFG],-1,"%d",num2);
5051 }
5052 else
5053 {
5054 textprintf_ex(menu1,f,sqr.x+txtoffs_double_1.x,sqr.y+txtoffs_double_1.y,jwin_pal[jcBOXFG],-1,"%d",num1);
5055 textprintf_ex(menu1,f,sqr.x+txtoffs_double_2.x,sqr.y+txtoffs_double_2.y,jwin_pal[jcBOXFG],-1,"%d",num2);
5056 }
5057 }
5058 void draw_sqr_btn(size_and_pos const& sqr, const char* txt, int flags, FONT* f = nullptr)
5059 {
5060 if(sqr.x < 0) return;
5061 FONT* tfont = font;
5062 if(f)
5063 font = f;
5064 draw_text_button(menu1, sqr.x, sqr.y, sqr.tw(), sqr.th(), txt, 0, 0, flags, true);
5065 font = tfont;
5066 }
5067 void draw_sqr_btn(size_and_pos const& sqr, int icon, int flags, FONT* f = nullptr)
5068 {
5069 if(sqr.x < 0) return;
5070 FONT* tfont = font;
5071 if(f)
5072 font = f;
5073 draw_icon_button(menu1, sqr.x, sqr.y, sqr.tw(), sqr.th(), icon, 0, 0, flags, true);
5074 font = tfont;
5075 }
5076
5077 void drawpanel()
5078 {
5079 mapscr *scr=Map.CurrScr();
5080 int32_t NextCombo = combobuf[Combo].nextcombo;
5081 int32_t NextCSet = combobuf[Combo].nextcset;
5082 if(combobuf[Combo].animflags & AF_CYCLEUNDERCOMBO)
5083 {
5084 NextCombo = scr->undercombo;
5085 NextCSet = scr->undercset;
5086 }
5087 if(combobuf[Combo].animflags & AF_CYCLENOCSET)
5088 NextCSet = CSet;
5089
5090 FONT* tfont = font;
5091 if(prv_mode)
5092 {
5093 jwin_draw_frame(menu1,0,preview_panel.y,preview_panel.x+preview_panel.w, preview_panel.h, FR_WIN);
5094 rectfill(menu1,preview_panel.x,preview_panel.y+2,preview_panel.x+preview_panel.w-3,preview_panel.y+preview_panel.h-3,jwin_pal[jcBOX]);
5095 }
5096 else
5097 {
5098 auto& sqr = main_panel;
5099 rectfill(menu1,sqr.x,sqr.y,sqr.x+sqr.w-1,sqr.y+sqr.h-1, jwin_pal[jcBOX]);
5100 refresh(rSCRMAP);
5101 jwin_draw_frame(menu1,sqr.x,sqr.y,sqr.w,sqr.h, FR_WIN);
5102
5103 font = get_custom_font(CFONT_GUI);
5104 draw_sqr_btn(squarepanel_swap_btn, "SWP", 0);
5105 if(compact_square_panels)
5106 {
5107 textprintf_centre_ex(menu1,font,squarepanel_up_btn.cx(),squarepanel_up_btn.y-text_height(font)-2,jwin_pal[jcBOXFG],-1,"%d",compact_active_panel);
5108 draw_sqr_btn(squarepanel_up_btn, BTNICON_ARROW_UP, 0);
5109 draw_sqr_btn(squarepanel_down_btn, BTNICON_ARROW_DOWN, 0);
5110 }
5111 font = tfont;
5112
5113 FONT* sqr_text_font = (is_compact && compact_square_panels) ? get_custom_font(CFONT_GUI) : font;
5114 //Item:
5115 if(itemsqr_pos.x > -1)
5116 {
5117 draw_sqr_frame(itemsqr_pos);
5118 if(scr->hasitem)
5119 {
5120 rectfill(menu1,itemsqr_pos.x+2,itemsqr_pos.y+2,itemsqr_pos.x+itemsqr_pos.tw()-3,itemsqr_pos.y+itemsqr_pos.th()-3,0);
5121 overtile16_scale(menu1, itemsbuf[scr->item].tile,itemsqr_pos.x+2,itemsqr_pos.y+2,itemsbuf[scr->item].csets&15,0,itemsqr_pos.tw()-4,itemsqr_pos.th()-4);
5122 }
5123 else draw_sqr_icon(itemsqr_pos, icon_bmp[0][coord_frame]);
5124 draw_sqr_nums(itemsqr_pos, sqr_text_font, panel_align == 1, scr->itemx, scr->itemy);
5125 }
5126 //Flag:
5127 if(flagsqr_pos.x > -1)
5128 {
5129 draw_sqr_frame(flagsqr_pos);
5130 draw_sqr_icon(flagsqr_pos,flag_bmp[Flag%16][coord_frame]);
5131 draw_sqr_nums(flagsqr_pos, sqr_text_font, panel_align == 1, Flag);
5132 }
5133
5134 //Stairs:
5135 if(stairsqr_pos.x > -1)
5136 {
5137 draw_sqr_frame(stairsqr_pos);
5138 draw_sqr_icon(stairsqr_pos,icon_bmp[1][coord_frame]);
5139 draw_sqr_nums(stairsqr_pos, sqr_text_font, panel_align == 1, scr->stairx, scr->stairy);
5140 }
5141
5142 //Green arrival square:
5143 bool disabled_arrival = get_qr(qr_NOARRIVALPOINT);
5144 if(warparrival_pos.x > -1)
5145 {
5146 draw_sqr_frame(warparrival_pos);
5147 BITMAP* icon = icon_bmp[2][coord_frame];
5148 if(disabled_arrival)
5149 {
5150 icon = create_bitmap_ex(8,16,16);
5151 blit(icon_bmp[2][0], icon, 0, 0, 0, 0, 16, 16);
5152 replColor(icon, 0xE7, 0xEA, 0xEA, false);
5153 replColor(icon, 0xE8, 0xE2, 0xE2, false);
5154 }
5155
5156 draw_sqr_icon(warparrival_pos, icon);
5157 draw_sqr_nums(warparrival_pos, sqr_text_font, panel_align == 1, scr->warparrivalx, scr->warparrivaly);
5158
5159 if(disabled_arrival)
5160 destroy_bitmap(icon);
5161 }
5162
5163 //Blue return squares:
5164 for(int32_t i=0; i<4; i++)
5165 {
5166 if(warpret_pos[i].x < 0) continue;
5167 draw_sqr_frame(warpret_pos[i]);
5168 draw_sqr_icon(warpret_pos[i], icon_bmp[ICON_BMP_RETURN_A+i][coord_frame]);
5169 draw_sqr_nums(warpret_pos[i], sqr_text_font, panel_align == 1, scr->warpreturnx[i], scr->warpreturny[i]);
5170 }
5171
5172 // Enemies
5173 auto& ep = enemy_prev_pos;
5174 if(ep.x > -1)
5175 {
5176 if(ep.fw > -1)
5177 {
5178 rectfill(menu1, ep.x, ep.y, ep.x+ep.tw()-1,ep.y+ep.th()-1,vc(0));
5179 rectfill(menu1, ep.x+ep.fw, ep.y+ep.fh, ep.x+ep.tw()-1, ep.y+ep.th()-1, jwin_pal[jcBOX]);
5180 jwin_draw_frag_frame(menu1, ep.x, ep.y, ep.tw(), ep.th(), ep.fw, ep.fh, FR_DEEP);
5181 }
5182 else
5183 {
5184 rectfill(menu1, ep.x, ep.y, ep.x+ep.tw()-1,ep.y+ep.th()-1,vc(0));
5185 draw_sqr_frame(ep);
5186 }
5187 for(int32_t i=0; i< 10 && Map.CurrScr()->enemy[i]!=0; i++)
5188 {
5189 int32_t id = Map.CurrScr()->enemy[i];
5190 int32_t tile = get_qr(qr_NEWENEMYTILES) ? guysbuf[id].e_tile : guysbuf[id].tile;
5191 int32_t cset = guysbuf[id].cset;
5192 auto& sqr = ep.subsquare(i);
5193 if(tile)
5194 overtile16_scale(menu1, tile+efrontfacingtile(id),sqr.x,sqr.y,cset,0,sqr.tw(),sqr.th());
5195 }
5196 }
5197 }
5198 font = tfont;
5199 }
5200
5201 void show_screen_error(const char *str, int32_t i, int32_t c)
5202 {
5203 rectfill(menu1, screrrorpos.x-text_length(get_zc_font(font_lfont_l),str),screrrorpos.y-(i*16),screrrorpos.x,screrrorpos.y-((i-1)*16)-4,vc(0));
5204 textout_shadowed_ex(menu1,get_zc_font(font_lfont_l), str,screrrorpos.x-text_length(get_zc_font(font_lfont_l),str),screrrorpos.y-(i*16),c,vc(0),-1);
5205 }
5206
5207 void tile_warp_notification(int32_t which, char *buf)
5208 {
5209 char letter = 'A'+which;
5210
5211 switch(Map.CurrScr()->tilewarptype[which])
5212 {
5213 case wtCAVE:
5214 sprintf(buf,"Tile Warp %c: Cave/Item Cellar",letter);
5215 break;
5216
5217 default:
5218 {
5219 char buf2[30];
5220
5221 if(strlen(DMaps[Map.CurrScr()->tilewarpdmap[which]].name)==0)
5222 {
5223 sprintf(buf2,"%d",Map.CurrScr()->tilewarpdmap[which]);
5224 }
5225 else
5226 sprintf(buf2,"%d-%s",Map.CurrScr()->tilewarpdmap[which],DMaps[Map.CurrScr()->tilewarpdmap[which]].name);
5227
5228 sprintf(buf,"Tile Warp %c: %s, %02X", letter, buf2, Map.CurrScr()->tilewarpscr[which]);
5229 break;
5230 }
5231
5232 case wtNOWARP:
5233 sprintf(buf,"Tile Warp %c: Cancel Warp", letter);
5234 break;
5235 }
5236 }
5237
5238 void side_warp_notification(int32_t which, int32_t dir, char *buf)
5239 {
5240 char letter = 'A'+which;
5241 char buf3[16];
5242
5243 if(dir==0 && Map.CurrScr()->timedwarptics)
5244 sprintf(buf3,"%s, Timed",mazedirstr[dir]);
5245 else if(dir==4)
5246 sprintf(buf3,"Timed");
5247 else
5248 strcpy(buf3, mazedirstr[dir]);
5249
5250 switch(Map.CurrScr()->sidewarptype[which])
5251 {
5252 case wtCAVE:
5253 sprintf(buf,"Side Warp %c (%s): Cave/Item Cellar",letter, buf3);
5254 break;
5255
5256 default:
5257 {
5258 // Destination DMap name
5259 if(strlen(DMaps[Map.CurrScr()->sidewarpdmap[which]].name)==0)
5260 {
5261 sprintf(buf,"Side Warp %c (%s): %d, %02X", letter, buf3, Map.CurrScr()->sidewarpdmap[which], Map.CurrScr()->sidewarpscr[which]);
5262 }
5263 else
5264 sprintf(buf,"Side Warp %c (%s): %d-%s, %02X", letter, buf3, Map.CurrScr()->sidewarpdmap[which],DMaps[Map.CurrScr()->sidewarpdmap[which]].name, Map.CurrScr()->sidewarpscr[which]);
5265
5266 break;
5267 }
5268
5269 case wtNOWARP:
5270 sprintf(buf,"Side Warp %c (%s): Cancel Warp", letter, buf3);
5271 break;
5272 }
5273 }
5274
5275 static bool arrowcursor = true; // Used by combo aliases and Combo Brush cursors. -L
5276
5277 void xout(BITMAP* dest, int x, int y, int x2, int y2, int c, int bgc = -1)
5278 {
5279 //BG Fill
5280 if(bgc > -1)
5281 rectfill(dest, x, y, x2, y2, bgc);
5282 ++x; ++y; --x2; --y2;
5283 //Border
5284 safe_rect(dest, x, y, x2, y2, c);
5285 //line(dest, x, y, x2, y, c);
5286 //line(dest, x, y, x, y2, c);
5287 //X
5288 line(dest, x, y, x2, y2, c);
5289 line(dest, x, y2, x2, y, c);
5290 }
5291
5292 void put_autocombo_engravings(BITMAP* dest, combo_auto const& ca, bool selected, int32_t x, int32_t y, int32_t scale)
5293 {
5294 if (!ca.valid())
5295 {
5296 if (ca.getDisplay() > 0)
5297 put_engraving(dest, x, y, 15, scale);
5298 }
5299 else
5300 {
5301 if (ca.getType() == AUTOCOMBO_Z4 || ca.getType() == AUTOCOMBO_DOR)
5302 {
5303 byte hei = vbound(ca.getArg() + 1, 1, 9);
5304 if (selected)
5305 hei = vbound(cauto_height, 1, 9);
5306 put_engraving(dest, x, y, 15 - hei, scale);
5307 }
5308 }
5309 }
5310
5311 void draw_screenunit_map_screen(VisibleScreen visible_screen)
5312 {
5313 int num_screens_to_draw = Map.getViewSize();
5314 int screen = visible_screen.screen;
5315 int xoff = visible_screen.xoff;
5316 int yoff = visible_screen.yoff;
5317
5318 mapscr* scr = visible_screen.scr;
5319 if (!layers_valid(scr))
5320 fix_layers(scr, true);
5321
5322 clear_to_color(mapscreenbmp, jwin_pal[jcBOX]);
5323 if (LayerDitherBG > -1)
5324 {
5325 if (LayerDitherSz > 0)
5326 ditherblit(mapscreenbmp, nullptr, vc(LayerDitherBG), dithChecker, LayerDitherSz);
5327 else
5328 clear_to_color(mapscreenbmp, vc(LayerDitherBG));
5329 }
5330
5331 int view_scr_x = Map.getViewScr() % 16;
5332 int view_scr_y = Map.getViewScr() / 16;
5333 int scr_x = screen % 16;
5334 int scr_y = screen / 16;
5335 int edge_xoff = 0, edge_yoff = 0;
5336 if(showedges)
5337 {
5338 if (scr_x == view_scr_x)
5339 edge_xoff = 16;
5340 else
5341 xoff -= 16;
5342
5343 if (scr_y == view_scr_y)
5344 edge_yoff = 16;
5345 else
5346 yoff -= 16;
5347 }
5348
5349 combotile_add_x = mapscreen_x + xoff;
5350 combotile_add_y = mapscreen_y + yoff;
5351 combotile_mul_x = mapscreen_single_scale;
5352 combotile_mul_y = mapscreen_single_scale;
5353 Map.draw(mapscreenbmp, scr_x == view_scr_x && showedges ? 16 : 0, scr_y == view_scr_y && showedges ? 16 : 0, Flags, Map.getCurrMap(), screen, ActiveLayerHighlight ? CurrentLayer : -1);
5354 combotile_add_x = 0;
5355 combotile_add_y = 0;
5356 combotile_mul_x = 1;
5357 combotile_mul_y = 1;
5358
5359 // TODO: should be better to move this out of draw_screenunit_map_screen.
5360 if (showedges && screen < 128)
5361 {
5362 bool peek_above = scr_y == view_scr_y;
5363 bool peek_below = scr_y == view_scr_y + num_screens_to_draw - 1;
5364 bool peek_left = scr_x == view_scr_x;
5365 bool peek_right = scr_x == view_scr_x + num_screens_to_draw - 1;
5366
5367 int right_col = 272 - (num_screens_to_draw > 1 ? 16 : 0);
5368 int bottom_row = 192 - (num_screens_to_draw > 1 ? 16 : 0);
5369
5370 //not the first row of screens
5371 if (peek_above)
5372 {
5373 if(screen>15 && !NoScreenPreview)
5374 {
5375 Map.drawrow(mapscreenbmp, edge_xoff, 0, Flags, 160, -1, screen-16);
5376 }
5377 else
5378 {
5379 Map.drawstaticrow(mapscreenbmp, edge_xoff, 0);
5380 }
5381 }
5382
5383 //not the last row of screens
5384 if (peek_below)
5385 {
5386 if(screen + 16 < 0x80 && !NoScreenPreview)
5387 {
5388 Map.drawrow(mapscreenbmp, edge_xoff, bottom_row, Flags, 0, -1, screen+16);
5389 }
5390 else
5391 {
5392 Map.drawstaticrow(mapscreenbmp, edge_xoff, bottom_row);
5393 }
5394 }
5395
5396 //not the first column of screens
5397 if (peek_left)
5398 {
5399 if(screen&0x0F && !NoScreenPreview)
5400 {
5401 Map.drawcolumn(mapscreenbmp, 0, edge_yoff, Flags, 15, -1, screen-1);
5402 }
5403 else
5404 {
5405 Map.drawstaticcolumn(mapscreenbmp, 0, edge_yoff);
5406 }
5407 }
5408
5409 //not the last column of screens
5410 if (peek_right)
5411 {
5412 if((screen&0x0F)<15 && !NoScreenPreview)
5413 {
5414 Map.drawcolumn(mapscreenbmp, right_col, edge_yoff, Flags, 0, -1, screen+1);
5415 }
5416 else
5417 {
5418 Map.drawstaticcolumn(mapscreenbmp, right_col, edge_yoff);
5419 }
5420 }
5421
5422 //not the first row or first column of screens
5423 if (peek_above && peek_left)
5424 {
5425 if((screen>15)&&(screen&0x0F) && !NoScreenPreview)
5426 {
5427 Map.drawblock(mapscreenbmp, 0, 0, Flags, 175, -1, screen-17);
5428 }
5429 else
5430 {
5431 Map.drawstaticblock(mapscreenbmp, 0, 0);
5432 }
5433 }
5434
5435 //not the first row or last column of screens
5436 if (peek_above && peek_right)
5437 {
5438 if((screen>15)&&((screen&0x0F)<15) && !NoScreenPreview)
5439 {
5440 Map.drawblock(mapscreenbmp, right_col, 0, Flags, 160, -1, screen-15);
5441 }
5442 else
5443 {
5444 Map.drawstaticblock(mapscreenbmp, right_col, 0);
5445 }
5446 }
5447
5448 //not the last row or first column of screens
5449 if (peek_below && peek_left)
5450 {
5451 if((screen<112)&&(screen&0x0F) && !NoScreenPreview)
5452 {
5453 Map.drawblock(mapscreenbmp, 0, bottom_row, Flags, 15, -1, screen+15);
5454 }
5455 else
5456 {
5457 Map.drawstaticblock(mapscreenbmp, 0, bottom_row);
5458 }
5459 }
5460
5461 //not the last row or last column of screens
5462 if (peek_below && peek_right)
5463 {
5464 if((screen<112)&&((screen&0x0F)<15) && !NoScreenPreview)
5465 {
5466 Map.drawblock(mapscreenbmp, right_col, bottom_row, Flags, 0, -1, screen+17);
5467 }
5468 else
5469 {
5470 Map.drawstaticblock(mapscreenbmp, right_col, bottom_row);
5471 }
5472 }
5473 }
5474
5475 if (ShowSquares && Map.getViewSize() < 4)
5476 {
5477 if(scr->stairx || scr->stairy)
5478 {
5479 int32_t x1 = scr->stairx+edge_xoff;
5480 int32_t y1 = scr->stairy+edge_yoff;
5481 safe_rect(mapscreenbmp,x1,y1,x1+15,y1+15,vc(14));
5482 }
5483
5484 if(scr->warparrivalx || scr->warparrivaly)
5485 {
5486 int32_t x1 = scr->warparrivalx +edge_xoff;
5487 int32_t y1 = scr->warparrivaly +edge_yoff;
5488 safe_rect(mapscreenbmp,x1,y1,x1+15,y1+15,vc(10));
5489 }
5490
5491 for(int32_t i=0; i<4; i++) if(scr->warpreturnx[i] || scr->warpreturny[i])
5492 {
5493 int32_t x1 = scr->warpreturnx[i]+edge_xoff;
5494 int32_t y1 = scr->warpreturny[i]+edge_yoff;
5495 int32_t clr = vc(9);
5496
5497 if(FlashWarpSquare==i)
5498 {
5499 if(!FlashWarpClk)
5500 FlashWarpSquare=-1;
5501 else if(!(--FlashWarpClk%3))
5502 clr = vc(15);
5503 }
5504
5505 safe_rect(mapscreenbmp,x1,y1,x1+15,y1+15,clr);
5506 }
5507 }
5508
5509 if(ShowFFCs)
5510 {
5511 mapscr* ffscr = prv_mode ? Map.get_prvscr() : scr;
5512 int num_ffcs = ffscr->numFFC();
5513 for(int32_t i=num_ffcs-1; i>=0; i--)
5514 {
5515 ffcdata& ff = ffscr->ffcs[i];
5516 if(ff.data !=0 && (ff.layer >= CurrentLayer || (ff.flags&ffc_overlay)))
5517 {
5518 auto x = ff.x+edge_xoff;
5519 auto y = ff.y+edge_yoff;
5520 safe_rect(mapscreenbmp, x+0, y+0, x+ff.txsz*16-1, y+ff.tysz*16-1, vc(12));
5521 }
5522 }
5523 }
5524
5525 if(!(Flags&cDEBUG) && pixeldb==1)
5526 {
5527 for(int32_t j=168; j<176; j++)
5528 {
5529 for(int32_t i=0; i<256; i++)
5530 {
5531 if(((i^j)&1)==0)
5532 {
5533 putpixel(mapscreenbmp,edge_xoff+i,
5534 edge_yoff+j,vc(blackout_color));
5535 }
5536 }
5537 }
5538 }
5539
5540 int w = mapscreenbmp->w * mapscreen_single_scale;
5541 int h = mapscreenbmp->h * mapscreen_single_scale;
5542 stretch_blit(mapscreenbmp, menu1, 0, 0, mapscreenbmp->w, mapscreenbmp->h, mapscreen_x + xoff, mapscreen_y + yoff, w, h);
5543 }
5544
5545 void draw_screenunit(int32_t unit, int32_t flags)
5546 {
5547 FONT* tfont = font;
5548 switch(unit)
5549 {
5550 case rSCRMAP:
5551 {
5552 size_and_pos *mini_sqr = &minimap;
5553 size_and_pos *real_mini_sqr = &real_minimap;
5554
5555 if(zoomed_minimap)
5556 {
5557 mini_sqr = &minimap_zoomed;
5558 real_mini_sqr = &real_minimap_zoomed;
5559 }
5560
5561 auto txt_x = real_mini_sqr->x+2+8*real_mini_sqr->xscale;
5562 auto txt_y = real_mini_sqr->y+2+8*real_mini_sqr->yscale;
5563
5564 rectfill(menu1, mini_sqr->x-1, mini_sqr->y-2,mini_sqr->x+mini_sqr->w-1,mini_sqr->y+mini_sqr->h-1,jwin_pal[jcBOX]);
5565 if(zoomed_minimap)
5566 jwin_draw_frame(menu1, mini_sqr->x-1, mini_sqr->y-2,mini_sqr->w,mini_sqr->h,FR_WIN);
5567 jwin_draw_minimap_frame(menu1,real_mini_sqr->x,real_mini_sqr->y,real_mini_sqr->tw(), real_mini_sqr->th(), real_mini_sqr->xscale, FR_DEEP);
5568
5569 if(Map.getCurrMap()<Map.getMapCount())
5570 {
5571 for(int32_t i=0; i<MAPSCRS; i++)
5572 {
5573 auto& sqr = real_mini_sqr->subsquare(i);
5574
5575 if(Map.Scr(i)->valid&mVALID)
5576 {
5577 // Handled by mmap_draw.
5578 }
5579 else
5580 {
5581 if (InvalidBG == 2)
5582 {
5583 draw_checkerboard(menu1, sqr.x, sqr.y, sqr.w);
5584 }
5585 else if (InvalidBG == 1)
5586 {
5587 for(int32_t dy=0; dy<sqr.h; dy++)
5588 {
5589 for(int32_t dx=0; dx<sqr.w; dx++)
5590 {
5591 menu1->line[dy+sqr.y][dx+sqr.x]=vc((((zc_oldrand()%100)/50)?0:8)+(((zc_oldrand()%100)/50)?0:7));
5592 }
5593 }
5594 }
5595 else
5596 {
5597 int32_t offs = 2*(sqr.w/9);
5598 draw_x(menu1, sqr.x+offs, sqr.y+offs, sqr.x+sqr.w-1-offs, sqr.y+sqr.h-1-offs, vc(15));
5599 }
5600 }
5601 }
5602
5603 int32_t s=Map.getCurrScr();
5604
5605 BITMAP* txtbmp = create_bitmap_ex(8,256,64);
5606 clear_bitmap(txtbmp);
5607 int txtscale = zoomed_minimap ? (is_compact ? 2 : 3) : 1;
5608 font = get_zc_font(font_lfont_l);
5609
5610 int32_t space = text_length(font, "255")+2, spc_s = text_length(font, "S")+2, spc_m = text_length(font, "M")+2;
5611 textprintf_disabled(txtbmp,font,0,0,jwin_pal[jcLIGHT],jwin_pal[jcMEDDARK],"M");
5612 static int map_shortcut_tooltip_id = ttip_register_id();
5613 ttip_install(map_shortcut_tooltip_id, "Prev map: ,\nNext map: .", txt_x, txt_y, 30, 20, txt_x, txt_y - 60);
5614
5615 textprintf_ex(txtbmp,font,spc_m,0,jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%-3d",Map.getCurrMap()+1);
5616
5617 textprintf_disabled(txtbmp,font,spc_m+space,0,jwin_pal[jcLIGHT],jwin_pal[jcMEDDARK],"S");
5618 textprintf_ex(txtbmp,font,spc_m+space+spc_s,0,jwin_pal[jcBOXFG],jwin_pal[jcBOX],"0x%02X (%d)",s, s);
5619 masked_stretch_blit(txtbmp, menu1, 0, 0, 256, 64, txt_x, txt_y, 256*txtscale, 64*txtscale);
5620 destroy_bitmap(txtbmp);
5621 }
5622 }
5623 break;
5624 case rMAP:
5625 {
5626 refresh_visible_screens();
5627 mapscreen_single_scale = (double)mapscreen_screenunit_scale / Map.getViewSize();
5628
5629 int num_combos_width = 16 * Map.getViewSize();
5630 int num_combos_height = 11 * Map.getViewSize();
5631
5632 if(CurrentLayer > 0 && !mapscreen_valid_layers[CurrentLayer-1])
5633 CurrentLayer = 0;
5634
5635 for (auto& vis_screen : visible_screens)
5636 {
5637 draw_screenunit_map_screen(vis_screen);
5638 }
5639
5640 if (showxypos_icon)
5641 {
5642 int x0 = showxypos_x + (showedges?16:0);
5643 int y0 = showxypos_y + (showedges?16:0);
5644 int x1 = x0 + showxypos_w - 1;
5645 int y1 = y0 + showxypos_h - 1;
5646 x0 *= mapscreen_single_scale;
5647 y0 *= mapscreen_single_scale;
5648 x1 *= mapscreen_single_scale;
5649 y1 *= mapscreen_single_scale;
5650 x0 += mapscreen_x;
5651 y0 += mapscreen_y;
5652 x1 += mapscreen_x;
5653 y1 += mapscreen_y;
5654
5655 if (showxypos_color == vc(15))
5656 safe_rect(menu1, x0, y0, x1, y1, showxypos_color);
5657 else
5658 rectfill(menu1, x0, y0, x1, y1, showxypos_color);
5659 }
5660
5661 if(showxypos_cursor_icon)
5662 {
5663 int x0 = showxypos_cursor_x + (showedges?16:0);
5664 int y0 = showxypos_cursor_y + (showedges?16:0);
5665 int x1 = x0 + showxypos_w - 1;
5666 int y1 = y0 + showxypos_h - 1;
5667 x0 *= mapscreen_single_scale;
5668 y0 *= mapscreen_single_scale;
5669 x1 *= mapscreen_single_scale;
5670 y1 *= mapscreen_single_scale;
5671 x0 += mapscreen_x;
5672 y0 += mapscreen_y;
5673 x1 += mapscreen_x;
5674 y1 += mapscreen_y;
5675 safe_rect(menu1, x0, y0, x1, y1, showxypos_cursor_color);
5676 }
5677
5678 // Draw dithering over the edge/preview combos.
5679 if(showedges)
5680 {
5681 int tile_size = 16 * mapscreen_single_scale;
5682 int tiles_across = (16 * Map.getViewSize()) + 2;
5683 int bottom_row_y = (Map.getViewSize()*11 + 1) * tile_size;
5684 int right_col_x = (Map.getViewSize()*16 + 1) * tile_size;
5685
5686 //top preview
5687 for(int32_t j=0; j<tile_size; j++)
5688 {
5689 for(int32_t i=0; i<tiles_across * tile_size; i++)
5690 {
5691 if(((i^j)&1)==0)
5692 {
5693 putpixel(menu1,mapscreen_x+i,mapscreen_y+j,vc(0));
5694 }
5695 }
5696 }
5697
5698 //bottom preview
5699 for(int32_t j = bottom_row_y; j < bottom_row_y + tile_size; j++)
5700 {
5701 for(int32_t i=0; i<tiles_across * tile_size; i++)
5702 {
5703 if(((i^j)&1)==0)
5704 {
5705 putpixel(menu1,mapscreen_x+i,mapscreen_y+j,vc(0));
5706 }
5707 }
5708 }
5709
5710 //left preview
5711 for(int32_t j=tile_size; j<int32_t(192*mapscreen_screenunit_scale); j++)
5712 {
5713 for(int32_t i=0; i<16*mapscreen_single_scale; i++)
5714 {
5715 if(((i^j)&1)==0)
5716 {
5717 putpixel(menu1,mapscreen_x+i,mapscreen_y+j,vc(0));
5718 }
5719 }
5720 }
5721
5722 //right preview
5723 for(int32_t j=tile_size; j<int32_t(192*mapscreen_screenunit_scale); j++)
5724 {
5725 for(int32_t i = right_col_x; i < right_col_x + tile_size; i++)
5726 {
5727 if(((i^j)&1)==0)
5728 {
5729 putpixel(menu1,mapscreen_x+i,mapscreen_y+j,vc(0));
5730 }
5731 }
5732 }
5733 }
5734
5735 if(!(Flags&cDEBUG) && pixeldb==2)
5736 {
5737 for(int32_t j=int32_t(168*mapscreen_single_scale); j<int32_t(176*mapscreen_single_scale); j++)
5738 {
5739 for(int32_t i=0; i<int32_t(256*mapscreen_single_scale); i++)
5740 {
5741
5742 if(((i^j)&1)==0)
5743 {
5744 putpixel(menu1,int32_t(mapscreen_x+(showedges?(16*mapscreen_single_scale):0)+i),
5745 int32_t(mapscreen_y+(showedges?(16*mapscreen_single_scale):0)+j),vc(blackout_color));
5746 }
5747 }
5748 }
5749 }
5750
5751 // TODO: This should move to `zmap::draw` (and delete the current code there doing a similar thing).
5752 if (Map.isDark(Map.getCurrScr()) && Map.getViewSize() == 1)
5753 {
5754 if((Flags&cNEWDARK) && get_qr(qr_NEW_DARKROOM))
5755 {
5756 BITMAP* tmpDark = create_bitmap_ex(8,16*16,16*11);
5757 BITMAP* tmpDarkTrans = create_bitmap_ex(8,16*16,16*11);
5758 BITMAP* tmpbuf = create_bitmap_ex(8,
5759 mapscreen_single_scale*(256+(showedges?32:0)),
5760 mapscreen_single_scale*(176+(showedges?32:0)));
5761 BITMAP* tmpbuf2 = create_bitmap_ex(8,
5762 mapscreen_single_scale*(256+(showedges?32:0)),
5763 mapscreen_single_scale*(176+(showedges?32:0)));
5764 int32_t darkCol = zinit.darkcol;
5765 switch(darkCol) //special cases
5766 {
5767 case BLACK:
5768 darkCol = vc(0);
5769 break;
5770 case WHITE:
5771 darkCol = vc(15);
5772 break;
5773 }
5774 clear_to_color(tmpDark, darkCol);
5775 clear_to_color(tmpDarkTrans, darkCol);
5776 clear_bitmap(tmpbuf);
5777 clear_bitmap(tmpbuf2);
5778 //Handle torch combos
5779 color_map = &trans_table2;
5780 Map.draw_darkness(tmpDark, tmpDarkTrans);
5781 //
5782 mapscr* tmp = Map.CurrScr();
5783 if(tmp->flags9 & fDARK_DITHER)
5784 {
5785 ditherblit(tmpDark, tmpDark, 0, zinit.dither_type, zinit.dither_arg);
5786 ditherblit(tmpDarkTrans, tmpDarkTrans, 0, zinit.dither_type, zinit.dither_arg);
5787 }
5788
5789 if(mapscreen_single_scale == 1)
5790 {
5791 blit(tmpDark, tmpbuf, 0, 0, (showedges?16:0), (showedges?16:0), 16*16, 16*11);
5792 blit(tmpDarkTrans, tmpbuf2, 0, 0, (showedges?16:0), (showedges?16:0), 16*16, 16*11);
5793 }
5794 else
5795 {
5796 stretch_blit(tmpDark, tmpbuf, 0, 0, 16*16, 16*11,
5797 (showedges?16:0)*mapscreen_single_scale, (showedges?16:0)*mapscreen_single_scale,
5798 (16*16)*mapscreen_single_scale, (16*11)*mapscreen_single_scale);
5799 stretch_blit(tmpDarkTrans, tmpbuf2, 0, 0, 16*16, 16*11,
5800 (showedges?16:0)*mapscreen_single_scale, (showedges?16:0)*mapscreen_single_scale,
5801 (16*16)*mapscreen_single_scale, (16*11)*mapscreen_single_scale);
5802 }
5803
5804 if(tmp->flags9 & fDARK_TRANS)
5805 {
5806 draw_trans_sprite(menu1, tmpbuf, mapscreen_x, mapscreen_y);
5807 }
5808 else
5809 {
5810 masked_blit(tmpbuf,menu1,0,0,mapscreen_x,mapscreen_y,tmpbuf->w,tmpbuf->h);
5811 }
5812 draw_trans_sprite(menu1, tmpbuf2, mapscreen_x, mapscreen_y);
5813 color_map = &trans_table;
5814 //
5815 destroy_bitmap(tmpDark);
5816 destroy_bitmap(tmpDarkTrans);
5817 destroy_bitmap(tmpbuf);
5818 destroy_bitmap(tmpbuf2);
5819 }
5820 else if(!(Flags&cNODARK))
5821 {
5822 for(int32_t j=0; j<80*mapscreen_single_scale; j++)
5823 {
5824 for(int32_t i=0; i<(80*mapscreen_single_scale)-j; i++)
5825 {
5826 if(((i^j)&1)==0)
5827 {
5828 putpixel(menu1,int32_t(mapscreen_x+(showedges?(16*mapscreen_single_scale):0))+i,
5829 int32_t(mapscreen_y+(showedges?(16*mapscreen_single_scale):0)+j),vc(blackout_color));
5830 }
5831 }
5832 }
5833 }
5834 }
5835
5836 double startx=mapscreen_x+(showedges?(16*mapscreen_single_scale):0);
5837 double starty=mapscreen_y+(showedges?(16*mapscreen_single_scale):0);
5838 bool inrect = isinRect(gui_mouse_x(),gui_mouse_y(),startx,starty,(startx+(256*mapscreen_screenunit_scale)-1),(starty+(176*mapscreen_screenunit_scale)-1));
5839
5840 if(!(flags&rNOCURSOR) && ((ComboBrush && !ComboBrushPause)||draw_mode==dm_alias) && inrect)
5841 {
5842 int mgridscale=16*mapscreen_single_scale;
5843 if(allowHideMouse)
5844 {
5845 if(arrowcursor)
5846 {
5847 arrowcursor = false;
5848 MouseSprite::set(ZQM_BLANK);
5849 }
5850 }
5851 else if(!arrowcursor)
5852 {
5853 arrowcursor = true;
5854 MouseSprite::set(ZQM_NORMAL);
5855 }
5856 ComboPosition pos = get_mapscreen_mouse_combo_pos();
5857 int32_t mx = pos.x * 16 * mapscreen_single_scale;
5858 int32_t my = pos.y * 16 * mapscreen_single_scale;
5859
5860 clear_bitmap(brushscreen);
5861 int32_t tempbw=BrushWidth;
5862 int32_t tempbh=BrushHeight;
5863
5864 if(draw_mode==dm_alias)
5865 {
5866 BrushWidth = combo_aliases[combo_apos].width+1;
5867 BrushHeight = combo_aliases[combo_apos].height+1;
5868 }
5869 else if(draw_mode == dm_cpool)
5870 {
5871 BrushWidth = BrushHeight = 1;
5872 combo_pool const& pool = combo_pools[combo_pool_pos];
5873 if(pool.valid())
5874 {
5875 int32_t cid = Combo;
5876 int8_t cset = CSet;
5877 pool.get_w_wrap(cid,cset,cpoolbrush_index/16); //divide to reduce speed
5878 put_combo(brushbmp,0,0,cid,cset,Flags&(cFLAGS|cWALK),0);
5879 }
5880 else clear_bitmap(brushbmp);
5881 }
5882 else if (draw_mode == dm_auto)
5883 {
5884 BrushWidth = BrushHeight = 1;
5885 }
5886
5887 stretch_blit(brushbmp, brushscreen, 0, 0, BrushWidth*16, BrushHeight*16, 0, 0, BrushWidth*mgridscale, BrushHeight*mgridscale);
5888 int float_offx = 0;
5889 int float_offy = 0;
5890
5891 if(FloatBrush)
5892 {
5893 float_offx = -SHADOW_DEPTH*mapscreen_single_scale;
5894 float_offy = -SHADOW_DEPTH*mapscreen_single_scale;
5895
5896 //shadow
5897 for(int x = 0; x < SHADOW_DEPTH*mapscreen_single_scale; ++x)
5898 for(int y = 0; y < (BrushHeight*mgridscale) + (SHADOW_DEPTH*mapscreen_single_scale); ++y)
5899 {
5900 if((((x^y)&1)==1) && y < 12*mgridscale)
5901 putpixel(brushscreen,x+(BrushWidth*mgridscale),y,vc(0));
5902 }
5903
5904 for(int x = 0; x < BrushWidth*mgridscale; ++x)
5905 for(int y = 0; y < SHADOW_DEPTH*mapscreen_single_scale; ++y)
5906 {
5907 if((((x^y)&1)==1) && x<16*mgridscale)
5908 putpixel(brushscreen,x,y+(BrushHeight*mgridscale),vc(0));
5909 }
5910 }
5911
5912 if(draw_mode==dm_alias)
5913 {
5914 combo_alias *combo = &combo_aliases[combo_apos];
5915
5916 if(BrushWidth > 1 && (alias_origin & 1)) //right-align
5917 float_offx -= (BrushWidth - 1) * mgridscale;
5918
5919 if(BrushHeight > 1 && (alias_origin & 2)) //bottom-align
5920 float_offy -= (BrushHeight - 1) * mgridscale;
5921 }
5922
5923 int bx = mapscreen_x + mx + float_offx + (showedges?(16*mapscreen_single_scale):0);
5924 int by = mapscreen_y + my + float_offy + (showedges?(16*mapscreen_single_scale):0);
5925 masked_blit(brushscreen, menu1, 0, 0, bx, by, 16*mgridscale, 11*mgridscale);
5926 BrushWidth=tempbw;
5927 BrushHeight=tempbh;
5928 }
5929 else
5930 {
5931 if(!arrowcursor)
5932 {
5933 MouseSprite::set(ZQM_NORMAL);
5934 arrowcursor = true;
5935 }
5936 }
5937
5938 int startxint = mapscreen_x+(showedges?int(16*mapscreen_single_scale):0);
5939 int startyint = mapscreen_y+(showedges?int(16*mapscreen_single_scale):0);
5940 int endxint = startx + 256*mapscreen_screenunit_scale - 1;
5941 int endyint = starty + 176*mapscreen_screenunit_scale - 1;
5942 set_clip_rect(menu1,startxint,startyint,endxint,endyint);
5943
5944 if(ShowGrid)
5945 {
5946 int w = num_combos_width;
5947 int h = num_combos_height;
5948 double tile_size = 16.0 / Map.getViewSize() * mapscreen_screenunit_scale;
5949
5950 if(showedges)
5951 {
5952 w += 2;
5953 h += 2;
5954 }
5955
5956 for (int x = 1; x < w; x++)
5957 {
5958 vline(menu1, mapscreen_x + x*tile_size, mapscreen_y, mapscreen_y + (h*tile_size)-1, vc(GridColor));
5959 }
5960
5961 for (int y = 1; y < h; y++)
5962 {
5963 hline(menu1, mapscreen_x, mapscreen_y + y*tile_size, mapscreen_x + (w*tile_size)-1, vc(GridColor));
5964 }
5965 }
5966
5967 if(ShowScreenGrid)
5968 {
5969 int w = num_combos_width;
5970 int h = num_combos_height;
5971 double tile_size = 16.0 / Map.getViewSize() * mapscreen_screenunit_scale;
5972 int startx = mapscreen_x + (showedges ? (16 * mapscreen_single_scale) : 0);
5973 int starty = mapscreen_y + (showedges ? (16 * mapscreen_single_scale) : 0);
5974
5975 if(showedges)
5976 {
5977 w += 1;
5978 h += 1;
5979 }
5980
5981 int color = (GridColor+8)%16;
5982
5983 for (int x = 16; x < w; x+=16)
5984 {
5985 vline(menu1, startx + x*tile_size, mapscreen_y, starty + (h*tile_size)-1, vc(color));
5986 }
5987
5988 for (int y = 11; y < h; y+=11)
5989 {
5990 hline(menu1, startx, starty + y*tile_size, startx + (w*tile_size)-1, vc(color));
5991 }
5992 }
5993
5994 // Draw a rect around regions.
5995 if (ShowRegionGrid && Map.getViewSize() > 1)
5996 {
5997 for (const auto& region_description : Map.get_region_descriptions())
5998 {
5999 int sx = region_description.screen % 16;
6000 int sy = region_description.screen / 16;
6001 int sw = region_description.w;
6002 int sh = region_description.h;
6003
6004 int mw = 256 * mapscreen_single_scale;
6005 int mh = 176 * mapscreen_single_scale;
6006 int mx = sx - (Map.getViewScr() % 16);
6007 int my = sy - (Map.getViewScr() / 16);
6008 int x0 = mapscreen_x + (showedges ? (16 * mapscreen_single_scale) : 0) + mx * mw;
6009 int y0 = mapscreen_y + (showedges ? (16 * mapscreen_single_scale) : 0) + my * mh;
6010 rect(menu1, x0+2, y0+2, x0 + mw*sw - 2, y0 + mh*sh - 2, vc(1));
6011 rect(menu1, x0+1, y0+1, x0 + mw*sw - 1, y0 + mh*sh - 1, vc(15));
6012 rect(menu1, x0, y0, x0 + mw*sw, y0 + mh*sh, vc(1));
6013 }
6014 }
6015
6016 // Draw a black-yellow-black rect around the currently selected screen.
6017 if (ShowCurScreenOutline && Map.getViewSize() > 1)
6018 {
6019 int mw = 256 * mapscreen_single_scale;
6020 int mh = 176 * mapscreen_single_scale;
6021 int mx = (Map.getCurrScr() % 16) - (Map.getViewScr() % 16);
6022 int my = (Map.getCurrScr() / 16) - (Map.getViewScr() / 16);
6023 int x0 = mapscreen_x + (showedges ? (16 * mapscreen_single_scale) : 0) + mx * mw;
6024 int y0 = mapscreen_y + (showedges ? (16 * mapscreen_single_scale) : 0) + my * mh;
6025 dotted_rect(menu1, x0+2, y0+2, x0 + mw - 2, y0 + mh - 2, vc(1), vc(0));
6026 rect(menu1, x0+1, y0+1, x0 + mw - 1, y0 + mh - 1, vc(14));
6027 dotted_rect(menu1, x0, y0, x0 + mw, y0 + mh, vc(1), vc(0));
6028 }
6029
6030 clear_clip_rect(menu1);
6031
6032 // Map tabs
6033 font = get_custom_font(CFONT_GUI);
6034
6035 map_page[current_mappage].map=Map.getCurrMap();
6036 map_page[current_mappage].screen=Map.getCurrScr();
6037
6038 for(int32_t btn=0; btn<mappage_count; ++btn)
6039 {
6040 char tbuf[15];
6041 sprintf(tbuf, "%d:%02X", map_page[btn].map+1, map_page[btn].screen);
6042 draw_layer_button(menu1,map_page_bar[btn].x, map_page_bar[btn].y, map_page_bar[btn].w, map_page_bar[btn].h,tbuf,(btn==current_mappage?D_SELECTED:0));
6043 }
6044 }
6045 break;
6046 case rCOMBOS:
6047 {
6048 auto real_h = combolist_window.h;
6049 jwin_draw_frame(menu1,combolist_window.x,combolist_window.y,combolist_window.w,real_h, FR_WIN);
6050 rectfill(menu1,combolist_window.x+2,combolist_window.y+2,combolist_window.x+combolist_window.w-3,combolist_window.y+real_h-3,jwin_pal[jcBOX]);
6051
6052 //Scrollers
6053 for(int32_t c = 0; c < num_combo_cols; ++c)
6054 {
6055 auto& pos = combolistscrollers[c];
6056
6057 { //Scroll up
6058 auto& p = pos.subsquare(0);
6059 jwin_draw_frame(menu1,p.x,p.y,p.w,p.h,FR_ETCHED);
6060
6061 for(int32_t i=0; i<3; i++)
6062 {
6063 hline(menu1, p.x+5-i, p.y+4+i, p.x+5+i, jwin_pal[jcBOXFG]);
6064 }
6065 }
6066
6067 { //Scroll down
6068 auto& p = pos.subsquare(1);
6069 jwin_draw_frame(menu1,p.x,p.y,p.w,p.h,FR_ETCHED);
6070
6071 for(int32_t i=0; i<3; i++)
6072 {
6073 hline(menu1,p.x+5-i,p.y+6-i, p.x+5+i, jwin_pal[jcBOXFG]);
6074 }
6075 }
6076 }
6077
6078 if(draw_mode==dm_alias)
6079 {
6080 if(LinkedScroll)
6081 {
6082 int tmp = current_comboalist;
6083 for(int q = tmp-1; q >= 0; --q)
6084 {
6085 combo_alistpos[q] = combo_alistpos[q+1]-(comboaliaslist[q].w*comboaliaslist[q].h);
6086 if(combo_alistpos[q] < 0)
6087 {
6088 tmp = 0;
6089 combo_alistpos[0] = 0;
6090 break;
6091 }
6092 }
6093 for(int q = tmp+1; q < num_combo_cols; ++q)
6094 combo_alistpos[q] = combo_alistpos[q-1]+(comboaliaslist[q-1].w*comboaliaslist[q-1].h);
6095 for(int q = 0; q < num_combo_cols; ++q)
6096 if(combo_apos >= combo_alistpos[q] && combo_apos < combo_alistpos[q] + (comboaliaslist[q].w*comboaliaslist[q].h))
6097 {
6098 current_comboalist = q;
6099 break;
6100 }
6101 }
6102 for(int32_t c = 0; c < num_combo_cols; ++c)
6103 {
6104 auto& pos = comboaliaslist[c];
6105 rectfill(menu1,pos.x,pos.y,pos.x+(pos.w*pos.xscale)-1,pos.y+(pos.h*pos.yscale)-1,0);
6106 jwin_draw_frame(menu1,pos.x-2,pos.y-2,(pos.w*pos.xscale)+4,(pos.h*pos.yscale)+4,FR_DEEP);
6107 }
6108
6109 auto& prev = comboalias_preview;
6110 jwin_draw_frame(menu1, prev.x-2, prev.y-2, prev.w+4, prev.h+4,FR_DEEP);
6111
6112 BITMAP *prv = create_bitmap_ex(8,64,64);
6113 clear_bitmap(prv);
6114 int32_t scalefactor = 1;
6115
6116 for(int32_t j=0; j<num_combo_cols; ++j)
6117 {
6118 auto per_page = (comboaliaslist[j].w * comboaliaslist[j].h);
6119 if(combo_alistpos[j] + per_page >= MAXCOMBOALIASES)
6120 combo_alistpos[j] = MAXCOMBOALIASES-per_page;
6121 auto& col = comboaliaslist[j];
6122 for(int32_t i=0; i<(comboaliaslist[j].w*comboaliaslist[j].h); i++)
6123 {
6124 draw_combo_alias_thumbnail(menu1, &combo_aliases[combo_alistpos[j]+i],
6125 (i%col.w)*col.xscale+col.x, (i/col.w)*col.yscale+col.y, col.xscale/16);
6126 }
6127
6128 if((combo_aliases[combo_apos].width>7)||(combo_aliases[combo_apos].height>7))
6129 {
6130 scalefactor=4;
6131 }
6132 else if((combo_aliases[combo_apos].width>3)||(combo_aliases[combo_apos].height>3))
6133 {
6134 scalefactor=2;
6135 }
6136
6137
6138 if(j==current_comboalist)
6139 {
6140 stretch_blit(brushbmp, prv, 0,0,scalefactor*64,zc_min(scalefactor*64,176),0,0,64,scalefactor==4?44:64);
6141 blit(prv,menu1,0,0,comboalias_preview.x,comboalias_preview.y,comboalias_preview.w,comboalias_preview.h);
6142
6143 int32_t rect_pos=combo_apos-combo_alistpos[current_comboalist];
6144
6145 if((rect_pos>=0)&&(rect_pos<(combo_alistpos[current_comboalist]+(col.w*col.h))))
6146 {
6147 int selw = col.xscale;
6148 int selh = col.yscale;
6149 int x1 = (rect_pos&(col.w-1))*col.xscale+col.x;
6150 int y1 = (rect_pos/col.w)*col.yscale+col.y;
6151 safe_rect(menu1,x1,y1,x1+selw-1,y1+selh-1,vc(CmbCursorCol),2);
6152 }
6153 }
6154 }
6155
6156 destroy_bitmap(prv);
6157 }
6158 else if(draw_mode==dm_cpool)
6159 {
6160 if(LinkedScroll)
6161 {
6162 int tmp = current_cpoollist;
6163 for(int q = tmp-1; q >= 0; --q)
6164 {
6165 combo_pool_listpos[q] = combo_pool_listpos[q+1]-(comboaliaslist[q].w*comboaliaslist[q].h);
6166 if(combo_pool_listpos[q] < 0)
6167 {
6168 tmp = 0;
6169 combo_pool_listpos[0] = 0;
6170 break;
6171 }
6172 }
6173 for(int q = tmp+1; q < num_combo_cols; ++q)
6174 combo_pool_listpos[q] = combo_pool_listpos[q-1]+(comboaliaslist[q-1].w*comboaliaslist[q-1].h);
6175 for(int q = 0; q < num_combo_cols; ++q)
6176 if(combo_pool_pos >= combo_pool_listpos[q] && combo_pool_pos < combo_pool_listpos[q] + (comboaliaslist[q].w*comboaliaslist[q].h))
6177 {
6178 current_cpoollist = q;
6179 break;
6180 }
6181 }
6182 for(int32_t c = 0; c < num_combo_cols; ++c)
6183 {
6184 auto& pos = comboaliaslist[c];
6185 rectfill(menu1,pos.x,pos.y,pos.x+(pos.w*pos.xscale)-1,pos.y+(pos.h*pos.yscale)-1,0);
6186 jwin_draw_frame(menu1,pos.x-2,pos.y-2,(pos.w*comboaliaslist[c].xscale)+4,(pos.h*comboaliaslist[c].yscale)+4,FR_DEEP);
6187 }
6188
6189 for (int32_t j = 0; j < num_combo_cols; ++j) //the actual panes
6190 {
6191 auto per_page = (comboaliaslist[j].w * comboaliaslist[j].h);
6192 if(combo_pool_listpos[j] + per_page >= MAXCOMBOPOOLS)
6193 combo_pool_listpos[j] = MAXCOMBOPOOLS-per_page;
6194 for(int32_t i=0; i<(comboaliaslist[j].w*comboaliaslist[j].h); i++)
6195 {
6196 int32_t cid=-1; int8_t cs=CSet;
6197 combo_pool const& cp = combo_pools[combo_pool_listpos[j]+i];
6198
6199 auto& list = comboaliaslist[j];
6200 if(cp.get_w(cid,cs,0) && !combobuf[cid].tile)
6201 {
6202 cid = -1; //no tile to draw
6203 }
6204 auto cx = (i%list.w)*list.xscale+list.x;
6205 auto cy = (i/list.w)*list.yscale+list.y;
6206 put_combo(menu1,cx,cy,cid,cs,Flags&(cFLAGS|cWALK),0,list.xscale/16);
6207 }
6208 }
6209 int32_t rect_pos=combo_pool_pos-combo_pool_listpos[current_cpoollist];
6210
6211 if((rect_pos>=0)&&(rect_pos<(combo_pool_listpos[current_cpoollist]+(comboaliaslist[current_cpoollist].w*comboaliaslist[current_cpoollist].h))))
6212 {
6213 int selw = comboaliaslist[current_cpoollist].xscale;
6214 int selh = comboaliaslist[current_cpoollist].yscale;
6215 int x1 = (rect_pos&(comboaliaslist[current_cpoollist].w-1))*comboaliaslist[current_cpoollist].xscale+comboaliaslist[current_cpoollist].x;
6216 int y1 = (rect_pos/comboaliaslist[current_cpoollist].w)*comboaliaslist[current_cpoollist].yscale+comboaliaslist[current_cpoollist].y;
6217 safe_rect(menu1,x1,y1,x1+selw-1,y1+selh-1,vc(CmbCursorCol),2);
6218 }
6219
6220 //Handle Preview
6221 combo_pool const& cpool = combo_pools[combo_pool_pos];
6222
6223 int32_t cid; int8_t cs;
6224 size_t total = weighted_cpool ? cpool.getTotalWeight() : cpool.combos.size();
6225 size_t ind = 0;
6226 size_t indw = combopool_preview.w/16;
6227 size_t indh = combopool_preview.h/16;
6228 size_t rows = total ? vbound(total/indw,1,indh) : 0;
6229 if (is_compact)
6230 rows = vbound(rows, 1, 3);
6231 else
6232 rows = vbound(rows, 1, 4);
6233 size_t real_height = rows*16;
6234
6235 cpool_prev_visible = rows > 0;
6236 if(rows)
6237 {
6238 jwin_draw_frame(menu1,combopool_preview.x-2,combopool_preview.y-2,
6239 combopool_preview.w+4,real_height+4,FR_DEEP);
6240 rectfill(menu1,combopool_preview.x,combopool_preview.y,
6241 combopool_preview.x+combopool_preview.w-1,
6242 combopool_preview.y+real_height-1,vc(0));
6243 draw_text_button(menu1,combopool_prevbtn.x,combopool_prevbtn.y,
6244 combopool_prevbtn.w,combopool_prevbtn.h,
6245 weighted_cpool ? "Weighted" : "Unweighted",vc(1),vc(14),0,true);
6246 if(!is_compact)
6247 textprintf_ex(menu1,font,combopool_prevbtn.x+combopool_prevbtn.w+5,
6248 combopool_prevbtn.y,jwin_pal[jcBOXFG],-1,"Preview");
6249 for(auto y = 0; y < real_height; y += 16)
6250 {
6251 for(auto x = 0; x < combopool_preview.w; x += 16, ++ind)
6252 {
6253 auto nx = combopool_preview.x+x, ny = combopool_preview.y+y;
6254 if(ind < total)
6255 {
6256 cs = CSet;
6257 if(weighted_cpool
6258 ? cpool.get_w(cid,cs,ind)
6259 : cpool.get_ind(cid,cs,ind))
6260 {
6261 put_combo(menu1,nx,ny,cid,cs,Flags&(cFLAGS|cWALK),0);
6262 continue;
6263 }
6264 }
6265 //No combo to display
6266 xout(menu1, nx, ny, nx+15, ny+15, vc(15));
6267 }
6268 }
6269 }
6270 }
6271 else if (draw_mode == dm_auto)
6272 {
6273 if (LinkedScroll)
6274 {
6275 int tmp = current_cautolist;
6276 for (int q = tmp - 1; q >= 0; --q)
6277 {
6278 combo_auto_listpos[q] = combo_auto_listpos[q + 1] - (comboaliaslist[q].w * comboaliaslist[q].h);
6279 if (combo_auto_listpos[q] < 0)
6280 {
6281 tmp = 0;
6282 combo_auto_listpos[0] = 0;
6283 break;
6284 }
6285 }
6286 for (int q = tmp + 1; q < num_combo_cols; ++q)
6287 combo_auto_listpos[q] = combo_auto_listpos[q - 1] + (comboaliaslist[q - 1].w * comboaliaslist[q - 1].h);
6288 for (int q = 0; q < num_combo_cols; ++q)
6289 if (combo_auto_pos >= combo_auto_listpos[q] && combo_auto_pos < combo_auto_listpos[q] + (comboaliaslist[q].w * comboaliaslist[q].h))
6290 {
6291 current_cautolist = q;
6292 break;
6293 }
6294 }
6295 for (int32_t c = 0; c < num_combo_cols; ++c)
6296 {
6297 auto& pos = comboaliaslist[c];
6298 rectfill(menu1, pos.x, pos.y, pos.x + (pos.w * pos.xscale) - 1, pos.y + (pos.h * pos.yscale) - 1, 0);
6299 jwin_draw_frame(menu1, pos.x - 2, pos.y - 2, (pos.w * comboaliaslist[c].xscale) + 4, (pos.h * comboaliaslist[c].yscale) + 4, FR_DEEP);
6300 }
6301
6302 for (int32_t j = 0; j < num_combo_cols; ++j) //the actual panes
6303 {
6304 auto per_page = (comboaliaslist[j].w * comboaliaslist[j].h);
6305 if(combo_auto_listpos[j] + per_page >= MAXAUTOCOMBOS)
6306 combo_auto_listpos[j] = MAXAUTOCOMBOS-per_page;
6307 for (int32_t i = 0; i < (comboaliaslist[j].w * comboaliaslist[j].h); i++)
6308 {
6309 int32_t cid = -1; int8_t cs = CSet;
6310 combo_auto const& ca = combo_autos[combo_auto_listpos[j] + i];
6311
6312 auto& list = comboaliaslist[j];
6313 cid = ca.getDisplay();
6314 if (cid == 0)
6315 cid = -1;
6316 auto cx = (i % list.w) * list.xscale + list.x;
6317 auto cy = (i / list.w) * list.yscale + list.y;
6318 put_combo(menu1, cx, cy, cid, cs, Flags & (cFLAGS | cWALK), 0, list.xscale / 16);
6319 put_autocombo_engravings(menu1, ca, combo_auto_listpos[j] + i == combo_auto_pos, cx, cy, list.xscale / 16);
6320 }
6321 }
6322 int32_t rect_pos = combo_auto_pos - combo_auto_listpos[current_cautolist];
6323
6324 if ((rect_pos >= 0) && (rect_pos < (combo_auto_listpos[current_cautolist] + (comboaliaslist[current_cautolist].w * comboaliaslist[current_cautolist].h))))
6325 {
6326 int selw = comboaliaslist[current_cautolist].xscale;
6327 int selh = comboaliaslist[current_cautolist].yscale;
6328 int x1 = (rect_pos & (comboaliaslist[current_cautolist].w - 1)) * comboaliaslist[current_cautolist].xscale + comboaliaslist[current_cautolist].x;
6329 int y1 = (rect_pos / comboaliaslist[current_cautolist].w) * comboaliaslist[current_cautolist].yscale + comboaliaslist[current_cautolist].y;
6330 safe_rect(menu1, x1, y1, x1 + selw - 1, y1 + selh - 1, vc(CmbCursorCol), 2);
6331
6332 combo_auto const& ca = combo_autos[combo_auto_pos];
6333 put_autocombo_engravings(menu1, ca, true, x1, y1, selw / 16);
6334 }
6335 }
6336 else
6337 {
6338 if(LinkedScroll)
6339 {
6340 int tmp = current_combolist;
6341 for(int q = tmp-1; q >= 0; --q)
6342 {
6343 First[q] = First[q+1]-(combolist[q].w*combolist[q].h);
6344 if(First[q] < 0)
6345 {
6346 tmp = 0;
6347 First[0] = 0;
6348 break;
6349 }
6350 }
6351 for(int q = tmp+1; q < num_combo_cols; ++q)
6352 First[q] = First[q-1]+(combolist[q-1].w*combolist[q-1].h);
6353 for(int q = 0; q < num_combo_cols; ++q)
6354 if(Combo >= First[q] && Combo < First[q] + (combolist[q].w*combolist[q].h))
6355 {
6356 current_combolist = q;
6357 break;
6358 }
6359 }
6360 for(int32_t c = 0; c < num_combo_cols; ++c)
6361 {
6362 auto& pos = combolist[c];
6363 rectfill(menu1,pos.x,pos.y,pos.x+(pos.w*pos.xscale)-1,pos.y+(pos.h*pos.yscale)-1,0);
6364 jwin_draw_frame(menu1,pos.x-2,pos.y-2,(pos.w*pos.xscale)+4,(pos.h*pos.yscale)+4,FR_DEEP);
6365 }
6366
6367 int32_t drawmap, drawscr;
6368 drawmap=Map.CurrScr()->layermap[CurrentLayer-1]-1;
6369 drawscr=Map.CurrScr()->layerscreen[CurrentLayer-1];
6370
6371 for(int32_t j=0; j<num_combo_cols; ++j)
6372 {
6373 auto per_page = (combolist[j].w * combolist[j].h);
6374 if(First[j] + per_page >= MAXCOMBOS)
6375 First[j] = MAXCOMBOS-per_page;
6376 for(int32_t i=0; i<(combolist[j].w*combolist[j].h); i++)
6377 {
6378 put_combo(menu1,(i%combolist[j].w)*combolist[j].xscale+combolist[j].x,
6379 (i/combolist[j].w)*combolist[j].yscale+combolist[j].y,
6380 i+First[j],CSet,Flags&(cFLAGS|cWALK),0,combolist[j].xscale/16);
6381 }
6382 }
6383
6384 int32_t rect_pos=Combo-First[current_combolist];
6385
6386 if((rect_pos>=0)&&(rect_pos<(combo_pool_listpos[current_combolist]+(combolist[current_combolist].w*combolist[current_combolist].h))))
6387 {
6388 int selw = (AutoBrush?BrushWidth:1)*combolist[current_combolist].xscale;
6389 int selh = (AutoBrush?BrushHeight:1)*combolist[current_combolist].yscale;
6390 int x1 = (rect_pos&(combolist[current_combolist].w-1))*combolist[current_combolist].xscale+combolist[current_combolist].x;
6391 int y1 = (rect_pos/combolist[current_combolist].w)*combolist[current_combolist].yscale+combolist[current_combolist].y;
6392 safe_rect(menu1,x1,y1,x1+selw-1,y1+selh-1,vc(CmbCursorCol),2);
6393 }
6394 }
6395 }
6396 break;
6397 case rCOMBO:
6398 {
6399 int32_t drawmap, drawscr;
6400 drawmap=Map.CurrScr()->layermap[CurrentLayer-1]-1;
6401 drawscr=Map.CurrScr()->layerscreen[CurrentLayer-1];
6402
6403 // Combo preview
6404 int32_t cid = Combo; int8_t cs = CSet;
6405 if(draw_mode == dm_alias)
6406 {
6407 cid = combo_aliases[combo_apos].combos[0];
6408 cs = wrap(combo_aliases[combo_apos].csets[0]+alias_cset_mod, 0, 13);
6409 }
6410 else if(draw_mode == dm_cpool)
6411 {
6412 combo_pool const& cpool = combo_pools[combo_pool_pos];
6413 cid = 0;
6414 cpool.get_w(cid,cs,0);
6415 }
6416 else if (draw_mode == dm_auto)
6417 {
6418 combo_auto const& cauto = combo_autos[combo_auto_pos];
6419 cid = cauto.getDisplay();
6420 }
6421 static BITMAP *combo_preview_bmp=create_bitmap_ex(8,32,32);
6422 static BITMAP *cycle_preview_bmp=create_bitmap_ex(8,32,32);
6423 // Combo
6424 put_combo(combo_preview_bmp,0,0,cid,cs,Flags&(cFLAGS|cWALK),0);
6425 jwin_draw_frame(menu1,combo_preview.x-2,combo_preview.y-2,combo_preview.w+4,combo_preview.h+4, FR_DEEP);
6426 stretch_blit(combo_preview_bmp, menu1, 0, 0, 16, 16, combo_preview.x, combo_preview.y, combo_preview.w, combo_preview.h);
6427
6428 comboprev_buf[0] = 0;
6429 comboprev_buf2[0] = 0;
6430 if(draw_mode == dm_cpool)
6431 {
6432 sprintf(comboprev_buf,"Pool: %d\nCSet: %d",combo_pool_pos,CSet);
6433 int x = combo_preview_text1.x+(combo_preview_text1.w*combo_preview_text1.xscale);
6434 textbox_out(menu1,txfont,x,combo_preview_text1.y,jwin_pal[jcBOXFG],jwin_pal[jcBOX],comboprev_buf,2,&combo_preview_text1);
6435 }
6436 else if (draw_mode == dm_auto)
6437 {
6438 GUI::ListData ac_types = GUI::ZCListData::autocombotypes();
6439 std::string type_name = ac_types.findText(combo_autos[combo_auto_pos].getType());
6440 if (is_compact)
6441 sprintf(comboprev_buf, "AC: %d CS: %d\n%s", combo_auto_pos, CSet, type_name.c_str());
6442 else
6443 sprintf(comboprev_buf, "Auto: %d CSet: %d\n%s\nEntries: %d", combo_auto_pos, CSet, type_name.c_str(), int32_t(combo_autos[combo_auto_pos].combos.size()));
6444 int x = combo_preview_text1.x + (combo_preview_text1.w * combo_preview_text1.xscale);
6445 textbox_out(menu1, txfont, x, combo_preview_text1.y, jwin_pal[jcBOXFG], jwin_pal[jcBOX], comboprev_buf, 2, &combo_preview_text1);
6446 }
6447 else if(draw_mode != dm_alias)
6448 {
6449 int x = combo_preview_text1.x+(combo_preview_text1.w*combo_preview_text1.xscale);
6450
6451 char shortbuf[512];
6452 char buf[256];
6453 strcpy(buf,combo_class_buf[combobuf[Combo].type].name);
6454 sprintf(comboprev_buf,"Combo: %d\nCSet: %d\n%s",Combo,CSet,buf);
6455 int ind = strlen(buf)-1;
6456 int x2 = x;
6457 if(x2 - text_length(txfont, buf) <= combolist_window.x)
6458 {
6459 auto dotlen = text_length(txfont, "..");
6460 x2 -= dotlen;
6461 while(x2 - text_length(txfont, buf) <= combolist_window.x)
6462 {
6463 if(ind < 0) break;
6464 buf[ind--] = '\0';
6465 }
6466 while(ind >= 0 && buf[ind] == ' ')
6467 buf[ind--] = 0; //trim spaces
6468 strcat(buf, "..");
6469 }
6470
6471 if(is_compact)
6472 {
6473 char b2[256];
6474 sprintf(b2, "Combo %d CS %d", Combo, CSet);
6475 if(x-text_length(txfont, b2) <= combolist_window.x)
6476 sprintf(b2, "Cmb %d CS %d", Combo, CSet);
6477 sprintf(shortbuf,"%s\n%s",b2,buf);
6478 }
6479 else sprintf(shortbuf,"Combo: %d\nCSet: %d\n%s",Combo,CSet,buf);
6480 textbox_out(menu1,txfont,x,combo_preview_text1.y,jwin_pal[jcBOXFG],jwin_pal[jcBOX],shortbuf,2,&combo_preview_text1);
6481 }
6482
6483 // Cycle
6484 if(!is_compact)
6485 {
6486 int32_t NextCombo = combobuf[Combo].nextcombo;
6487 int32_t NextCSet = combobuf[Combo].nextcset;
6488 if(combobuf[Combo].animflags & AF_CYCLEUNDERCOMBO)
6489 {
6490 mapscr* scr = Map.CurrScr();
6491 NextCombo = scr->undercombo;
6492 NextCSet = scr->undercset;
6493 }
6494 if(combobuf[Combo].animflags & AF_CYCLENOCSET)
6495 NextCSet = CSet;
6496 bool normal_dm = draw_mode != dm_alias && draw_mode != dm_cpool && draw_mode != dm_auto;
6497 jwin_draw_frame(menu1,combo_preview2.x-2,combo_preview2.y-2,combo_preview2.w+4,combo_preview2.h+4, FR_DEEP);
6498 if(NextCombo>0 && normal_dm)
6499 {
6500 put_combo(cycle_preview_bmp,0,0,NextCombo,NextCSet,Flags&(cFLAGS|cWALK),0);
6501
6502 if(Flags&cWALK) put_walkflags(cycle_preview_bmp,0,0,NextCombo,0);
6503
6504 if(Flags&cFLAGS) put_flags(cycle_preview_bmp,0,0,NextCombo,0,cFLAGS,0);
6505
6506 stretch_blit(cycle_preview_bmp, menu1, 0, 0, 16, 16, combo_preview2.x, combo_preview2.y, combo_preview2.w, combo_preview2.h);
6507 }
6508 else
6509 {
6510 if (InvalidBG == 2)
6511 {
6512 draw_checkerboard(menu1, combo_preview2.x, combo_preview2.y, 32);
6513 }
6514 else if(InvalidBG == 1)
6515 {
6516 for(int32_t dy=0; dy<combo_preview2.w; dy++)
6517 {
6518 for(int32_t dx=0; dx<combo_preview2.w; dx++)
6519 {
6520 menu1->line[dy+combo_preview2.y][dx+combo_preview2.x]=vc((((zc_oldrand()%100)/50)?0:8)+(((zc_oldrand()%100)/50)?0:7));
6521 }
6522 }
6523 }
6524 else
6525 {
6526 rectfill(menu1, combo_preview2.x,combo_preview2.y, combo_preview2.x+32,combo_preview2.y+combo_preview2.h,vc(0));
6527 safe_rect(menu1, combo_preview2.x,combo_preview2.y, combo_preview2.x+32,combo_preview2.y+combo_preview2.h,vc(15));
6528 line(menu1, combo_preview2.x,combo_preview2.y, combo_preview2.x+32,combo_preview2.y+combo_preview2.h,vc(15));
6529 line(menu1, combo_preview2.x,combo_preview2.y+combo_preview2.h, combo_preview2.x+32,combo_preview2.y,vc(15));
6530 }
6531 }
6532
6533 if(normal_dm)
6534 {
6535 char shortbuf[512];
6536 char buf[256];
6537 strcpy(buf,combo_class_buf[combobuf[NextCombo].type].name);
6538 sprintf(comboprev_buf2, "Cycle: %d\nCSet: %d\n%s", NextCombo, NextCSet, buf);
6539 int ind = strlen(buf)-1;
6540 int x2 = combo_preview_text2.x;
6541 if(x2 + text_length(txfont, buf) > zq_screen_w-2)
6542 {
6543 auto dotlen = text_length(txfont, "..");
6544 x2 += dotlen;
6545 while(x2 + text_length(txfont, buf) > zq_screen_w-2)
6546 {
6547 if(ind < 0) break;
6548 buf[ind--] = '\0';
6549 }
6550 while(ind >= 0 && buf[ind] == ' ')
6551 buf[ind--] = 0; //trim spaces
6552 strcat(buf, "..");
6553 }
6554
6555 sprintf(shortbuf, "Cycle: %d\nCSet: %d\n%s", NextCombo, NextCSet, buf);
6556 textbox_out(menu1,txfont,combo_preview_text2.x,combo_preview_text2.y,jwin_pal[jcBOXFG],jwin_pal[jcBOX],shortbuf,0,&combo_preview_text2);
6557 }
6558 }
6559
6560 font = get_zc_font(font_lfont_l);
6561 bool merged = is_compact ? compact_merged_combopane : large_merged_combopane;
6562 draw_text_button(menu1,combo_merge_btn.x,combo_merge_btn.y,combo_merge_btn.w,combo_merge_btn.h,merged ? "<|>" : ">|<",vc(1),vc(14),0,true);
6563 }
6564 break;
6565 case rFAVORITES:
6566 {
6567 font = get_zc_font(font_lfont_l);
6568
6569 jwin_draw_frame(menu1,favorites_window.x,favorites_window.y,favorites_window.w,favorites_window.h, FR_WIN);
6570 rectfill(menu1,favorites_window.x+2,favorites_window.y+2,favorites_window.x+favorites_window.w-3,favorites_window.y+favorites_window.h-3,jwin_pal[jcBOX]);
6571 jwin_draw_frame(menu1,favorites_list.x-2,favorites_list.y-2,(favorites_list.w*favorites_list.xscale)+4,(favorites_list.h*favorites_list.yscale)+4, FR_DEEP);
6572 rectfill(menu1,favorites_list.x,favorites_list.y,favorites_list.x+(favorites_list.w*favorites_list.xscale)-1,favorites_list.y+(favorites_list.h*favorites_list.yscale)-1,jwin_pal[jcBOXFG]);
6573
6574 textprintf_ex(menu1,get_zc_font(font_lfont_l),favorites_list.x-2,favorites_list.y-15,jwin_pal[jcBOXFG],-1,is_compact ? "Favorites" : "Favorite Combos");
6575 BITMAP* subb = create_bitmap_ex(8,16,16);
6576
6577 for(int32_t col=0; col<favorites_list.w; ++col)
6578 {
6579 for(int32_t row=0; row<favorites_list.h; ++row)
6580 {
6581 auto i = (row*FAVORITECOMBO_PER_ROW)+col+FAVORITECOMBO_PER_PAGE*FavoriteComboPage;
6582 auto& sqr = favorites_list.subsquare(col,row);
6583 if(i >= MAXFAVORITECOMBOS || favorite_combos[i]==-1)
6584 {
6585 if (InvalidBG == 2)
6586 {
6587 draw_checkerboard(menu1, sqr.x, sqr.y, sqr.w);
6588 }
6589 else if(InvalidBG == 1)
6590 {
6591 for(int32_t dy=0; dy<sqr.h; dy++)
6592 {
6593 for(int32_t dx=0; dx<sqr.w; dx++)
6594 {
6595 menu1->line[sqr.y+dy][sqr.x+dx]=vc((((zc_oldrand()%100)/50)?0:8)+(((zc_oldrand()%100)/50)?0:7));
6596 }
6597 }
6598 }
6599 else
6600 {
6601 xout(menu1, sqr.x, sqr.y, sqr.x+sqr.w-1, sqr.y+sqr.h-1, vc(15), vc(0));
6602 }
6603 }
6604 else
6605 {
6606 clear_bitmap(subb);
6607 bool repos = combotile_override_x < 0 && combotile_override_y < 0;
6608
6609 switch(favorite_combo_modes[i])
6610 {
6611 case dm_alias:
6612 draw_combo_alias_thumbnail(subb, &combo_aliases[favorite_combos[i]], 0, 0, 1);
6613 if (ShowFavoriteComboModes)
6614 put_engraving(subb, 0, 0, 0x3E, 1);
6615 break;
6616 case dm_cpool:
6617 {
6618 int32_t cid = -1; int8_t cs = CSet;
6619 combo_pool const& cp = combo_pools[favorite_combos[i]];
6620
6621 if (cp.get_w(cid, cs, 0) && !combobuf[cid].tile)
6622 cid = -1; //no tile to draw
6623 put_combo(subb, 0, 0, cid, cs, 0, 0);
6624 if (ShowFavoriteComboModes)
6625 put_engraving(subb, 0, 0, 0x3D, 1);
6626 break;
6627 }
6628 case dm_auto:
6629 {
6630 int32_t cid = -1; int8_t cs = CSet;
6631 combo_auto const& ca = combo_autos[favorite_combos[i]];
6632
6633 cid = ca.getDisplay();
6634 if (cid == 0)
6635 cid = -1;
6636 put_combo(subb, 0, 0, cid, cs, 0, 0);
6637 if (ShowFavoriteComboModes)
6638 put_engraving(subb, 0, 0, 0x3C, 1);
6639 break;
6640 }
6641 default:
6642 if (repos)
6643 {
6644 combotile_override_x = sqr.x + (sqr.w - 16) / 2;
6645 combotile_override_y = sqr.y + (sqr.h - 16) / 2;
6646 }
6647 put_combo(subb, 0, 0, favorite_combos[i], CSet, Flags & (cFLAGS | cWALK), 0);
6648 if (repos) combotile_override_x = combotile_override_y = -1;
6649 }
6650 stretch_blit(subb, menu1, 0, 0, 16, 16, sqr.x, sqr.y, sqr.w, sqr.h);
6651 }
6652 }
6653 }
6654
6655 destroy_bitmap(subb);
6656
6657 bool zoomed = is_compact ? compact_zoomed_fav : large_zoomed_fav;
6658 if(!is_compact)
6659 textprintf_right_ex(menu1, get_zc_font(font_lfont_l), favorites_pgleft.x - 2, favorites_pgleft.y, jwin_pal[jcBOXFG], -1, "%d/9", FavoriteComboPage + 1);
6660
6661 draw_text_button(menu1, favorites_pgleft.x, favorites_pgleft.y, favorites_pgleft.w, favorites_pgleft.h, is_compact ? "<" : "<-", vc(1), vc(14), 0, true);
6662 draw_text_button(menu1, favorites_pgright.x, favorites_pgright.y, favorites_pgright.w, favorites_pgright.h, is_compact ? ">" : "->", vc(1), vc(14), 0, true);
6663 draw_text_button(menu1,favorites_zoombtn.x,favorites_zoombtn.y,favorites_zoombtn.w,favorites_zoombtn.h,zoomed ? "-" : "+",vc(1),vc(14),0,true);
6664 draw_text_button(menu1,favorites_x.x,favorites_x.y,favorites_x.w,favorites_x.h,"X",vc(1),vc(14),0,true);
6665 draw_text_button(menu1,favorites_infobtn.x,favorites_infobtn.y,favorites_infobtn.w,favorites_infobtn.h,"?",vc(1),vc(14),0,true);
6666 }
6667 break;
6668 case rCOMMANDS:
6669 {
6670 jwin_draw_frame(menu1,commands_window.x,commands_window.y,commands_window.w,commands_window.h, FR_WIN);
6671 rectfill(menu1,commands_window.x+2,commands_window.y+2,commands_window.x+commands_window.w-3,commands_window.y+commands_window.h-3,jwin_pal[jcBOX]);
6672 jwin_draw_frame(menu1,commands_list.x-2,commands_list.y-2,(commands_list.w*commands_list.xscale)+4,(commands_list.h*commands_list.yscale)+4, FR_DEEP);
6673 rectfill(menu1,commands_list.x,commands_list.y,commands_list.x+(commands_list.w*commands_list.xscale)-1,commands_list.y+(commands_list.h*commands_list.yscale)-1,jwin_pal[jcBOXFG]);
6674 font=get_custom_font(CFONT_FAVCMD);
6675
6676 for(int32_t cmd=0; cmd<(commands_list.w*commands_list.h); ++cmd)
6677 {
6678 uint hkey = favorite_commands[cmd];
6679 draw_layer_button(menu1,
6680 (cmd%commands_list.w)*commands_list.xscale+commands_list.x,
6681 (cmd/commands_list.w)*commands_list.yscale+commands_list.y,
6682 commands_list.xscale,
6683 commands_list.yscale,
6684 get_hotkey_name(hkey),
6685 (selected_hotkey(hkey)?D_SELECTED:0) | (disabled_hotkey(hkey)?D_DISABLED:0));
6686 }
6687
6688 font = get_zc_font(font_lfont_l);
6689 if(commands_txt.x > 0)
6690 {
6691 gui_textout_ln(menu1, get_zc_font(font_lfont_l), (ucc*)"Favorite Commands", commands_txt.x, commands_txt.y, jwin_pal[jcBOXFG], -1, 0);
6692 }
6693
6694 bool zoomed = is_compact ? compact_zoomed_cmd : large_zoomed_cmd;
6695 draw_text_button(menu1,commands_zoombtn.x,commands_zoombtn.y,commands_zoombtn.w,commands_zoombtn.h,zoomed ? "-" : "+",vc(1),vc(14),0,true);
6696 draw_text_button(menu1,commands_x.x,commands_x.y,commands_x.w,commands_x.h,"X",vc(1),vc(14),0,true);
6697 draw_text_button(menu1,commands_infobtn.x,commands_infobtn.y,commands_infobtn.w,commands_infobtn.h,"?",vc(1),vc(14),0,true);
6698 }
6699 break;
6700 }
6701 font = tfont;
6702 }
6703
6704 bool pause_refresh = true;
6705 bool is_refreshing = false;
6706 11 void refresh(int32_t flags, bool update)
6707 {
6708
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(pause_refresh) return;
6709 static bool refreshing = false;
6710
6711 int num_screens_to_draw = Map.getViewSize();
6712
6713 bool earlyret = refreshing;
6714 is_refreshing = refreshing = true;
6715 //^ These prevent recursive calls from updating the screen early
6716
6717 bool zoom_delay = (zoomed_minimap && flags != rSCRMAP);
6718 if(zoom_delay)
6719 flags &= ~rSCRMAP;
6720
6721 if(flags&rCLEAR)
6722 {
6723 //magic pink = 0xED
6724 //system black = vc(0)
6725 //Clear a4 menu
6726 clear_to_color(menu1,jwin_pal[jcBOX]);
6727
6728 //Clears should refresh everything!
6729 flags |= rALL;
6730 }
6731
6732 if(flags&rSCRMAP)
6733 draw_screenunit(rSCRMAP,flags);
6734
6735 if(flags&rMAP)
6736 draw_screenunit(rMAP,flags);
6737
6738 if((flags&rCOMBOS) || (draw_mode == dm_cpool && (flags&rFAVORITES)))
6739 draw_screenunit(rCOMBOS,flags);
6740
6741 if(flags&(rCOMBO|rCOMBOS))
6742 draw_screenunit(rCOMBO,flags);
6743
6744 if(flags&rMENU)
6745 drawpanel();
6746
6747 if(flags&rFAVORITES)
6748 draw_screenunit(rFAVORITES,flags);
6749
6750 if(flags&rCOMMANDS)
6751 draw_screenunit(rCOMMANDS,flags);
6752
6753 FONT* tfont = font;
6754 font = get_custom_font(CFONT_GUI);
6755 jwin_draw_frame(menu1,layer_panel.x,layer_panel.y,layer_panel.w,layer_panel.h,FR_DEEP);
6756 rectfill(menu1,layer_panel.x,layer_panel.y,layer_panel.x+layer_panel.w-1,layer_panel.y+layer_panel.h-1,jwin_pal[jcBOX]);
6757
6758 for(int32_t i=0; i<=6; ++i)
6759 {
6760 char tbuf[15];
6761
6762 if (i>0 && mapscreen_valid_layers[i - 1] && num_screens_to_draw == 1)
6763 {
6764 if(is_compact)
6765 sprintf(tbuf, "%s%d %d:%02X", (i==2 && Map.CurrScr()->flags7&fLAYER2BG) || (i==3 && Map.CurrScr()->flags7&fLAYER3BG) ? "-":"", i, Map.CurrScr()->layermap[i-1], Map.CurrScr()->layerscreen[i-1]);
6766 else sprintf(tbuf, "%s%d (%d:%02X)", (i==2 && Map.CurrScr()->flags7&fLAYER2BG) || (i==3 && Map.CurrScr()->flags7&fLAYER3BG) ? "-":"", i, Map.CurrScr()->layermap[i-1], Map.CurrScr()->layerscreen[i-1]);
6767 }
6768 else
6769 {
6770 sprintf(tbuf, "%s%d", (i==2 && Map.CurrScr()->flags7&fLAYER2BG) || (i==3 && Map.CurrScr()->flags7&fLAYER3BG) ? "-":"", i);
6771 }
6772
6773 int32_t spacing_offs = is_compact ? 2 : 10;
6774 int32_t rx = (i * (layerpanel_buttonwidth+spacing_offs+layerpanel_checkbox_wid)) + layer_panel.x+(is_compact?2:6);
6775 int32_t ry = layer_panel.y;
6776 auto cbyofs = (layerpanel_buttonheight-layerpanel_checkbox_hei)/2;
6777 draw_layer_button(menu1, rx, ry, layerpanel_buttonwidth, layerpanel_buttonheight, tbuf, CurrentLayer==i? D_SELECTED : ( i > 0 && !mapscreen_valid_layers[i-1]) ? D_DISABLED : 0);
6778 draw_checkbox(menu1,rx+layerpanel_buttonwidth+1,ry+cbyofs,layerpanel_checkbox_wid,layerpanel_checkbox_hei,LayerMaskInt[i]!=0);
6779 }
6780
6781 font=tfont;
6782
6783 // } //if(true)
6784 if(zq_showpal)
6785 {
6786 for(int32_t i=0; i<256; i++)
6787 {
6788 rectfill(menu1,((i&15)<<2)+256,((i>>4)<<2)+176,((i&15)<<2)+259,((i>>4)<<2)+179,i);
6789 }
6790 }
6791 { //Show top-left info
6792 size_t maxwid = (mapscreen_screenunit_scale*mapscreenbmp->w)-1;
6793 size_t maxhei = (mapscreen_screenunit_scale*mapscreenbmp->w);
6794 set_clip_rect(menu1,mapscreen_x,mapscreen_y,mapscreen_x+maxwid-1,mapscreen_y+maxhei-1);
6795 FONT* showfont = get_custom_font(CFONT_INFO);
6796 int showfont_h = text_height(showfont);
6797 int32_t ypos = mapscreen_y;
6798 if(prv_mode)
6799 {
6800 textout_shadowed_ex(menu1,showfont,"Preview Mode",0,ypos,vc(15),vc(0),infobg?vc(0):-1);
6801 ypos += showfont_h+1;
6802 if(prv_twon)
6803 {
6804 textprintf_shadowed_ex(menu1,showfont,0,ypos,vc(15),vc(0),infobg?vc(0):-1,"T Warp=%d tics", Map.get_prvtime());
6805 ypos += showfont_h+1;
6806 }
6807 }
6808 if(ShowFPS)
6809 {
6810 textprintf_shadowed_ex(menu1,showfont,0,ypos,vc(15),vc(0),infobg?vc(0):-1,"FPS: %3d",lastfps);
6811 ypos += showfont_h+1;
6812 }
6813
6814 if(ShowFFScripts && !prv_mode)
6815 {
6816 word num_ffcs = Map.CurrScr()->numFFC();
6817 for(word i=0; i< num_ffcs; i++)
6818 {
6819 if(ypos+showfont_h-1 > map_page_bar[0].y)
6820 break;
6821 if(Map.CurrScr()->ffcs[i].script && Map.CurrScr()->ffcs[i].data)
6822 {
6823 textout_shadowed_ex(menu1, showfont, ffcmap[Map.CurrScr()->ffcs[i].script-1].scriptname.substr(0,300).c_str(),0,ypos,vc(showxypos_ffc==i ? 14 : 15),vc(0),infobg?vc(0):-1);
6824 ypos+=showfont_h+1;
6825 }
6826 }
6827 }
6828 clear_clip_rect(menu1);
6829 if(prv_mode)
6830 do_previewtext();
6831 }
6832 // Show Errors & Details
6833 //This includes the presence of: Screen State Carryover, Timed Warp, Maze Path, the 'Sideview Gravity', 'Invisible Hero',
6834 //'Save Screen', 'Continue Here' and 'Treat As..' Screen Flags,
6835 // the String, every Room Type and Catch All, and all four Tile and Side Warps.
6836 if(!prv_mode && ShowInfo)
6837 {
6838 int32_t i=0;
6839 char buf[2048];
6840
6841 // Start with general information
6842 if(Map.CurrScr()->flags3&fINVISHERO)
6843 {
6844 sprintf(buf,"Invisible Hero");
6845 show_screen_error(buf,i++,vc(15));
6846 }
6847
6848 if(Map.getLayerTargetMap() > 0)
6849 {
6850 Map.setlayertarget(); //Now the text does not carry over when changing maps, but shifting back, it does not **re-appear** until you change screens.
6851 //It was also required to set some updates in onDecMap and onIncMap. #
6852 //This fixes Screen Info not displaying properly when changing maps. -Z
6853 //Needed to refresh the screen info. -Z ( 26th March, 2019 )
6854 int32_t m = Map.getLayerTargetMultiple();
6855 sprintf(buf,"Used as a layer by screen %d:%02X",Map.getLayerTargetMap(),Map.getLayerTargetScr());
6856 char buf2[24];
6857
6858 if(m>0)
6859 {
6860 sprintf(buf2," and %d other%s",m,m>1?"s":"");
6861 strcat(buf,buf2);
6862 }
6863
6864 show_screen_error(buf,i++,vc(15));
6865 }
6866
6867 if(Map.CurrScr()->nextmap)
6868 {
6869 sprintf(buf,"Screen State carries over to %d:%02X",Map.CurrScr()->nextmap,Map.CurrScr()->nextscr);
6870 show_screen_error(buf,i++,vc(15));
6871 }
6872
6873 if(Map.CurrScr()->timedwarptics)
6874 {
6875 sprintf(buf,"%s%sTimed Warp: %s",(Map.CurrScr()->flags4&fTIMEDDIRECT)?"Direct ":"",(Map.CurrScr()->flags5&fRANDOMTIMEDWARP)?"Random ":"",ticksstr(Map.CurrScr()->timedwarptics));
6876 show_screen_error(buf,i++,vc(15));
6877 }
6878
6879 if(Map.CurrScr()->flags&fMAZE)
6880 {
6881 sprintf(buf,"Maze Path: %s (Exit %s)",pathstr(Map.CurrScr()->path),mazedirstr[Map.CurrScr()->exitdir]);
6882 show_screen_error(buf,i++,vc(15));
6883 }
6884
6885 bool continuescreen = false, savecombo = false;
6886
6887 if(Map.CurrScr()->flags4&fAUTOSAVE)
6888 {
6889 sprintf(buf,"Automatic Save%s Screen", (Map.CurrScr()->flags6&fCONTINUEHERE) ? "-Continue":"");
6890 show_screen_error(buf,i++,vc(15));
6891 continuescreen = ((Map.CurrScr()->flags6&fCONTINUEHERE)!=0);
6892 savecombo = true;
6893 }
6894 else if(Map.CurrScr()->flags6&fCONTINUEHERE)
6895 {
6896 sprintf(buf,"Continue Screen");
6897 show_screen_error(buf,i++,vc(15));
6898 continuescreen = true;
6899 }
6900
6901 if(isSideViewGravity())
6902 {
6903 sprintf(buf,"Sideview Gravity");
6904 show_screen_error(buf,i++,vc(15));
6905 }
6906
6907 if(Map.CurrScr()->flags6 & (fCAVEROOM|fDUNGEONROOM))
6908 {
6909 sprintf(buf,"Treat As %s%s Screen", (Map.CurrScr()->flags6&fCAVEROOM) ? "Interior":"NES Dungeon",
6910 (Map.CurrScr()->flags6 & (fCAVEROOM|fDUNGEONROOM)) == (fCAVEROOM|fDUNGEONROOM) ? " or NES Dungeon":"");
6911 show_screen_error(buf,i++,vc(15));
6912 }
6913
6914 if(Map.CurrScr()->oceansfx != 0)
6915 {
6916 sprintf(buf,"Ambient Sound: %s",sfx_string[Map.CurrScr()->oceansfx]);
6917 show_screen_error(buf,i++,vc(15));
6918 }
6919
6920 if(Map.CurrScr()->bosssfx != 0)
6921 {
6922 sprintf(buf,"Boss Roar Sound: %s",sfx_string[Map.CurrScr()->bosssfx]);
6923 show_screen_error(buf,i++,vc(15));
6924 }
6925
6926 if(Map.CurrScr()->str)
6927 {
6928 strncpy(buf,MsgString(Map.CurrScr()->str, true, false),72);
6929 buf[72] = '\0';
6930 char shortbuf[72];
6931 strip_extra_spaces(buf);
6932 shorten_string(shortbuf, buf, get_zc_font(font_lfont_l), 72, 280);
6933 sprintf(buf,"String %s",shortbuf);
6934 show_screen_error(buf,i++,vc(15));
6935 }
6936
6937 if((Map.CurrScr()->flags&fWHISTLE) || (Map.CurrScr()->flags7&fWHISTLEWATER))
6938 {
6939 sprintf(buf,"Whistle ->%s%s%s",(Map.CurrScr()->flags&fWHISTLE)?" Stairs":"",
6940 (Map.CurrScr()->flags&fWHISTLE && Map.CurrScr()->flags7&fWHISTLEWATER)?", ":"",
6941 (Map.CurrScr()->flags7&fWHISTLEWATER)?"Dry Lake":"");
6942 show_screen_error(buf,i++,vc(15));
6943 }
6944
6945 switch(Map.CurrScr()->room)
6946 {
6947 case rSP_ITEM:
6948 sprintf(buf,"Special Item is %s",item_string[Map.CurrScr()->catchall]);
6949 show_screen_error(buf,i++, vc(15));
6950 break;
6951
6952 case rINFO:
6953 {
6954 int32_t shop = Map.CurrScr()->catchall;
6955 sprintf(buf,"Pay For Info: -%d, -%d, -%d",
6956 QMisc.info[shop].price[0],QMisc.info[shop].price[1],QMisc.info[shop].price[2]);
6957 show_screen_error(buf,i++, vc(15));
6958 }
6959 break;
6960
6961 case rMONEY:
6962 sprintf(buf,"Secret Money: %d Rupees",Map.CurrScr()->catchall);
6963 show_screen_error(buf,i++, vc(15));
6964 break;
6965
6966 case rGAMBLE:
6967 show_screen_error("Gamble Room",i++, vc(15));
6968 break;
6969
6970 case rREPAIR:
6971 sprintf(buf,"Door Repair: -%d Rupees",Map.CurrScr()->catchall);
6972 show_screen_error(buf,i++, vc(15));
6973 break;
6974
6975 case rRP_HC:
6976 sprintf(buf,"Take %s or %s", item_string[iRPotion], item_string[iHeartC]);
6977 show_screen_error(buf,i++, vc(15));
6978 break;
6979
6980 case rGRUMBLE:
6981 show_screen_error("Feed the Goriya",i++, vc(15));
6982 break;
6983
6984 case rTRIFORCE:
6985 show_screen_error("Triforce Check",i++, vc(15));
6986 break;
6987
6988 case rP_SHOP:
6989 case rSHOP:
6990 {
6991 int32_t shop = Map.CurrScr()->catchall;
6992 sprintf(buf,"%sShop: ",
6993 Map.CurrScr()->room==rP_SHOP ? "Potion ":"");
6994
6995 for(int32_t j=0; j<3; j++) if(QMisc.shop[shop].item[j]>0) // Print the 3 items and prices
6996 {
6997 strcat(buf,item_string[QMisc.shop[shop].item[j]]);
6998 strcat(buf,":");
6999 char pricebuf[8];
7000 sprintf(pricebuf,"%d",QMisc.shop[shop].price[j]);
7001 strcat(buf,pricebuf);
7002
7003 if(j<2 && QMisc.shop[shop].item[j+1]>0) strcat(buf,", ");
7004 }
7005
7006 show_screen_error(buf,i++, vc(15));
7007 }
7008 break;
7009
7010 case rBOTTLESHOP:
7011 {
7012 int32_t shop = Map.CurrScr()->catchall;
7013 sprintf(buf,"Bottle Shop: ");
7014
7015 for(int32_t j=0; j<3; j++) if(QMisc.bottle_shop_types[shop].fill[j]>0) // Print the 3 fills and prices
7016 {
7017 strcat(buf,QMisc.bottle_types[QMisc.bottle_shop_types[shop].fill[j]-1].name);
7018 strcat(buf,":");
7019 char pricebuf[8];
7020 sprintf(pricebuf,"%d",QMisc.bottle_shop_types[shop].price[j]);
7021 strcat(buf,pricebuf);
7022
7023 if(j<2 && QMisc.bottle_shop_types[shop].fill[j+1]>0) strcat(buf,", ");
7024 }
7025
7026 show_screen_error(buf,i++, vc(15));
7027 }
7028 break;
7029
7030 case rTAKEONE:
7031 {
7032 int32_t shop = Map.CurrScr()->catchall;
7033 sprintf(buf,"Take Only One: %s%s%s%s%s",
7034 QMisc.shop[shop].item[0]<1?"":item_string[QMisc.shop[shop].item[0]],QMisc.shop[shop].item[0]>0?", ":"",
7035 QMisc.shop[shop].item[1]<1?"":item_string[QMisc.shop[shop].item[1]],(QMisc.shop[shop].item[1]>0&&QMisc.shop[shop].item[2]>0)?", ":"",
7036 QMisc.shop[shop].item[2]<1?"":item_string[QMisc.shop[shop].item[2]]);
7037 show_screen_error(buf,i++, vc(15));
7038 }
7039 break;
7040
7041 case rBOMBS:
7042 sprintf(buf,"More Bombs: -%d Rupees",Map.CurrScr()->catchall);
7043 show_screen_error(buf,i++, vc(15));
7044 break;
7045
7046 case rARROWS:
7047 sprintf(buf,"More Arrows: -%d Rupees",Map.CurrScr()->catchall);
7048 show_screen_error(buf,i++, vc(15));
7049 break;
7050
7051 case rSWINDLE:
7052 sprintf(buf,"Leave Life or %d Rupees",Map.CurrScr()->catchall);
7053 show_screen_error(buf,i++, vc(15));
7054 break;
7055
7056 case r10RUPIES:
7057 show_screen_error("10 Rupees",i++, vc(15));
7058 break;
7059
7060 case rGANON:
7061 show_screen_error("Ganon Room",i++, vc(15));
7062 break;
7063
7064 case rZELDA:
7065 show_screen_error("Zelda Room",i++, vc(15));
7066 break;
7067
7068 case rMUPGRADE:
7069 show_screen_error("1/2 Magic Upgrade",i++, vc(15));
7070 break;
7071
7072 case rLEARNSLASH:
7073 show_screen_error("Learn Slash",i++, vc(15));
7074 break;
7075
7076 case rWARP:
7077 sprintf(buf,"3-Stair Warp: Warp Ring %d",Map.CurrScr()->catchall);
7078 show_screen_error(buf,i++, vc(15));
7079 break;
7080 }
7081
7082 bool undercombo = false, warpa = false, warpb = false, warpc = false, warpd = false, warpr = false;
7083
7084 word num_ffcs = Map.CurrScr()->numFFC();
7085 for(int32_t c=0; c<176+128+1+num_ffcs; ++c)
7086 {
7087 // Checks both combos, secret combos, undercombos and FFCs
7088 //Fixme:
7089 int32_t ctype =
7090 combobuf[vbound(
7091 (c>=305 ? Map.CurrScr()->ffcs[c-305].data :
7092 c>=304 ? Map.CurrScr()->undercombo :
7093 c>=176 ? Map.CurrScr()->secretcombo[c-176] :
7094 !Map.CurrScr()->valid ? 0 : // Sanity check: does room combo data exist?
7095 Map.CurrScr()->data[c]
7096 ), 0, MAXCOMBOS-1)].type;
7097
7098 if(!undercombo && integrityBoolUnderCombo(Map.CurrScr(),ctype))
7099 {
7100 undercombo = true;
7101 show_screen_error("Under Combo is combo 0",i++, vc(7));
7102 }
7103
7104 // Tile Warp types
7105 switch(ctype)
7106 {
7107 case cSAVE:
7108 case cSAVE2:
7109 if(!savecombo)
7110 {
7111 savecombo = true;
7112
7113 if(integrityBoolSaveCombo(Map.CurrScr(),ctype))
7114 show_screen_error("Save Screen",i++, vc(15));
7115 else
7116 show_screen_error("Save-Continue Screen",i++, vc(15));
7117 }
7118
7119 break;
7120
7121 case cSTAIRR:
7122 case cPITR:
7123 case cSWARPR:
7124 if(!warpr && (Map.CurrScr()->tilewarptype[0]==wtCAVE || Map.CurrScr()->tilewarptype[1]==wtCAVE ||
7125 Map.CurrScr()->tilewarptype[2]==wtCAVE || Map.CurrScr()->tilewarptype[3]==wtCAVE))
7126 {
7127 warpr = true;
7128 show_screen_error("Random Tile Warp contains Cave/Item Cellar",i++, vc(7));
7129 }
7130
7131 break;
7132
7133 case cCAVED:
7134 case cPITD:
7135 case cSTAIRD:
7136 case cCAVE2D:
7137 case cSWIMWARPD:
7138 case cDIVEWARPD:
7139 case cSWARPD:
7140 if(!warpd)
7141 {
7142 warpd = true;
7143 tile_warp_notification(3,buf);
7144 show_screen_error(buf,i++, vc(15));
7145 }
7146
7147 break;
7148
7149 case cCAVEC:
7150 case cPITC:
7151 case cSTAIRC:
7152 case cCAVE2C:
7153 case cSWIMWARPC:
7154 case cDIVEWARPC:
7155 case cSWARPC:
7156 if(!warpc)
7157 {
7158 warpc = true;
7159 tile_warp_notification(2,buf);
7160 show_screen_error(buf,i++, vc(15));
7161 }
7162
7163 break;
7164
7165 case cCAVEB:
7166 case cPITB:
7167 case cSTAIRB:
7168 case cCAVE2B:
7169 case cSWIMWARPB:
7170 case cDIVEWARPB:
7171 case cSWARPB:
7172 if(!warpb)
7173 {
7174 warpb = true;
7175 tile_warp_notification(1,buf);
7176 show_screen_error(buf,i++, vc(15));
7177 }
7178
7179 break;
7180
7181 case cCAVE:
7182 case cPIT:
7183 case cSTAIR:
7184 case cCAVE2:
7185 case cSWIMWARP:
7186 case cDIVEWARP:
7187 case cSWARPA:
7188 if(!warpa)
7189 {
7190 warpa = true;
7191 tile_warp_notification(0,buf);
7192 show_screen_error(buf,i++, vc(15));
7193 }
7194
7195 break;
7196 }
7197 }
7198
7199 int32_t sidewarpnotify = 0;
7200
7201 if(Map.CurrScr()->flags2&wfUP)
7202 {
7203 side_warp_notification(Map.CurrScr()->sidewarpindex&3,0,buf);
7204 show_screen_error(buf,i++, vc(15));
7205 sidewarpnotify|=(1<<(Map.CurrScr()->sidewarpindex&3));
7206 }
7207
7208 if(Map.CurrScr()->flags2&wfDOWN)
7209 {
7210 side_warp_notification((Map.CurrScr()->sidewarpindex>>2)&3,1,buf);
7211 show_screen_error(buf,i++, vc(15));
7212 sidewarpnotify|=(1<<((Map.CurrScr()->sidewarpindex>>2)&3));
7213 }
7214
7215 if(Map.CurrScr()->flags2&wfLEFT)
7216 {
7217 side_warp_notification((Map.CurrScr()->sidewarpindex>>4)&3,2,buf);
7218 show_screen_error(buf,i++, vc(15));
7219 sidewarpnotify|=(1<<((Map.CurrScr()->sidewarpindex>>4)&3));
7220 }
7221
7222 if(Map.CurrScr()->flags2&wfRIGHT)
7223 {
7224 side_warp_notification((Map.CurrScr()->sidewarpindex>>6)&3,3,buf);
7225 show_screen_error(buf,i++, vc(15));
7226 sidewarpnotify|=(1<<((Map.CurrScr()->sidewarpindex>>6)&3));
7227 }
7228
7229 if(!(sidewarpnotify&1) && Map.CurrScr()->timedwarptics)
7230 {
7231 side_warp_notification(0,4,buf); // Timed Warp
7232 show_screen_error(buf,i++, vc(15));
7233 }
7234
7235 // Now for errors
7236 if((Map.CurrScr()->flags4&fSAVEROOM) && !savecombo) show_screen_error("Save Point->Continue Here, but no Save Point combo?",i++, vc(14));
7237
7238 if(integrityBoolEnemiesItem(Map.CurrScr())) show_screen_error("Enemies->Item, but no enemies",i++, vc(7));
7239
7240 if(integrityBoolEnemiesSecret(Map.CurrScr())) show_screen_error("Enemies->Secret, but no enemies",i++, vc(7));
7241
7242 if(integrityBoolGuyNoString(Map.CurrScr())) show_screen_error("Non-Fairy Guy, but String is (none)",i++, vc(14));
7243
7244 if(integrityBoolRoomNoGuy(Map.CurrScr())) show_screen_error("Guy is (none)",i++, vc(14));
7245
7246 if(integrityBoolRoomNoString(Map.CurrScr())) show_screen_error("String is (none)",i++, vc(14));
7247
7248 if(integrityBoolRoomNoGuyNoString(Map.CurrScr())) show_screen_error("Guy and String are (none)",i++, vc(14));
7249 }
7250
7251 if(zoom_delay)
7252 draw_screenunit(rSCRMAP,flags);
7253
7254
7255 if(flags&rCLEAR)
7256 {
7257 //Draw the whole gui
7258 blit(menu1,screen,0,0,0,0,zq_screen_w,zq_screen_h);
7259 }
7260 else
7261 {
7262 blit(menu1,screen,0,16,0,16,zq_screen_w,zq_screen_h-16);
7263 blit(menu1,screen,combolist_window.x-64,0,combolist_window.x-64,0,combolist_window.w+64,16);
7264
7265 if(flags&rCOMBO)
7266 blit(menu1,screen,combo_preview.x,combo_preview.y,combo_preview.x,combo_preview.y,combo_preview.w,combo_preview.h);
7267 }
7268
7269 if(earlyret)
7270 return;
7271
7272 //Draw the Main Menu
7273 rectfill(screen,mainbar.x,mainbar.y,mainbar.x+mainbar.w-1,mainbar.y+mainbar.h-1,jwin_pal[jcBOX]);
7274 jwin_draw_frame(screen,mainbar.x,mainbar.y,mainbar.w,mainbar.h,FR_WIN);
7275
7276 FONT* oldfont = font;
7277 font = get_custom_font(CFONT_GUI);
7278
7279 //Drawmode button
7280 draw_text_button(screen,drawmode_btn.x,drawmode_btn.y,drawmode_btn.w,drawmode_btn.h,dm_names[draw_mode],vc(1),vc(14),0,true);
7281 //Compact button
7282 draw_text_button(screen,compactbtn.x, compactbtn.y, compactbtn.w, compactbtn.h, is_compact ? "< Expand" : "> Compact", vc(1),vc(14),0,true);
7283 //Zoom buttons
7284 zoom_in_btn_disabled = num_screens_to_draw == 1;
7285 zoom_out_btn_disabled = num_screens_to_draw == mapscreen_num_screens_to_draw_max;
7286 draw_text_button(screen,zoominbtn.x, zoominbtn.y, zoominbtn.w, zoominbtn.h, "+", vc(1),vc(14),zoom_in_btn_disabled ? D_DISABLED : 0,true);
7287 draw_text_button(screen,zoomoutbtn.x, zoomoutbtn.y, zoomoutbtn.w, zoomoutbtn.h, "-", vc(1),vc(14),zoom_out_btn_disabled ? D_DISABLED : 0,true);
7288
7289 font = oldfont;
7290
7291 d_nbmenu_proc(MSG_DRAW, &dialogs[0], 0);
7292
7293 ComboBrushPause=0;
7294
7295 SCRFIX();
7296 if(update)
7297 custom_vsync();
7298 is_refreshing = refreshing = false;
7299 11 }
7300
7301 12 static int minimap_tooltip_id = ttip_register_id();
7302
7303 void select_scr()
7304 {
7305 if(Map.getCurrMap()>=Map.getMapCount())
7306 return;
7307
7308 int32_t tempcb=ComboBrush;
7309 ComboBrush=0;
7310
7311 size_and_pos const& real_mini = zoomed_minimap ? real_minimap_zoomed : real_minimap;
7312
7313 //scooby
7314 while(gui_mouse_b())
7315 {
7316 int32_t x=gui_mouse_x();
7317 int32_t y=gui_mouse_y();
7318
7319 int32_t ind = real_mini.rectind(x,y);
7320
7321 if(ind>=MAPSCRS)
7322 ind-=16;
7323
7324 if(ind > -1 && ind != Map.getCurrScr())
7325 {
7326 Map.setCurrScr(ind);
7327 }
7328
7329 custom_vsync();
7330 refresh(rALL);
7331 }
7332
7333 ComboBrush=tempcb;
7334 }
7335
7336 void clear_cpool()
7337 {
7338 for(int32_t i=0; i<MAXFAVORITECOMBOS; ++i)
7339 {
7340 pool_combos[i].clear();
7341 }
7342 pool_dirty = true;
7343 }
7344
7345 bool select_favorite()
7346 {
7347 int32_t tempcb=ComboBrush;
7348 ComboBrush=0;
7349 bool valid=false;
7350
7351 while(gui_mouse_b())
7352 {
7353 valid=false;
7354 int32_t x=gui_mouse_x();
7355
7356 if(x<favorites_list.x)
7357 x=favorites_list.x;
7358
7359 if(x>favorites_list.x+(favorites_list.w*favorites_list.xscale)-1)
7360 x=favorites_list.x+(favorites_list.w*favorites_list.xscale)-1;
7361
7362 int32_t y=gui_mouse_y();
7363
7364 if(y<favorites_list.y)
7365 y=favorites_list.y;
7366
7367 if(y>favorites_list.y+(favorites_list.h*favorites_list.yscale)-1)
7368 y=favorites_list.y+(favorites_list.h*favorites_list.yscale)-1;
7369
7370 int32_t tempc=(((y-favorites_list.y)/favorites_list.yscale)*FAVORITECOMBO_PER_ROW)+((x-favorites_list.x)/favorites_list.xscale) + FAVORITECOMBO_PER_PAGE * FavoriteComboPage;
7371
7372 if(tempc >= MAXFAVORITECOMBOS)
7373 {
7374 //Nothing, invalid
7375 }
7376 else
7377 {
7378 if(favorite_combos[tempc]!=-1)
7379 {
7380 switch(favorite_combo_modes[tempc])
7381 {
7382 case dm_alias:
7383 draw_mode = dm_alias;
7384 combo_apos = favorite_combos[tempc];
7385 break;
7386 case dm_cpool:
7387 draw_mode = dm_cpool;
7388 combo_pool_pos = favorite_combos[tempc];
7389 break;
7390 case dm_auto:
7391 draw_mode = dm_auto;
7392 combo_auto_pos = favorite_combos[tempc];
7393 break;
7394 default:
7395 draw_mode = dm_normal;
7396 Combo = favorite_combos[tempc];
7397 }
7398 if(AutoBrush)
7399 BrushWidth = BrushHeight = 1;
7400 valid=true;
7401 fix_drawing_mode_menu();
7402 }
7403 }
7404
7405 custom_vsync();
7406 refresh(rALL);
7407 }
7408
7409 ComboBrush=tempcb;
7410 return valid;
7411 }
7412
7413 void select_combo(int32_t clist)
7414 {
7415 current_combolist=clist;
7416 int32_t tempcb=ComboBrush;
7417 ComboBrush=0;
7418
7419 int autobrush_cx = -1, autobrush_cy = -1;
7420 int autobrush_first = First[current_combolist];
7421 auto& curlist = combolist[current_combolist];
7422 AutoBrushRevert = (key[KEY_ALT]||key[KEY_ALTGR]);
7423 while(gui_mouse_b())
7424 {
7425 int32_t x=gui_mouse_x();
7426
7427 if(x<curlist.x)
7428 x=curlist.x;
7429
7430 if(x>curlist.x+(curlist.w*curlist.xscale)-1)
7431 x=curlist.x+(curlist.w*curlist.xscale)-1;
7432
7433 int32_t y=gui_mouse_y();
7434
7435 if(y<curlist.y)
7436 y=curlist.y;
7437
7438 if(y>curlist.y+(curlist.h*curlist.yscale)-1)
7439 y=curlist.y+(curlist.h*curlist.yscale)-1;
7440
7441 int cx = ((x-curlist.x)/curlist.xscale), cy = ((y-curlist.y)/curlist.yscale);
7442 if(AutoBrush)
7443 {
7444 if(autobrush_cx < 0)
7445 {
7446 autobrush_cx = cx;
7447 autobrush_cy = cy;
7448 }
7449 BrushWidth = vbound(abs(autobrush_cx-cx)+1,1,16);
7450 BrushHeight = vbound(abs(autobrush_cy-cy)+1,1,11);
7451 cx = std::min(autobrush_cx,cx);
7452 cy = std::min(autobrush_cy,cy);
7453 }
7454 Combo=(cy*curlist.w)+cx+First[current_combolist];
7455 custom_vsync();
7456 refresh(rALL);
7457 if(AutoBrush) //Prevent any scrolling
7458 First[current_combolist] = autobrush_first;
7459 }
7460 if(key[KEY_ALT]||key[KEY_ALTGR])
7461 AutoBrushRevert = true;
7462 position_mouse_z(0);
7463 ComboBrush=tempcb;
7464 }
7465
7466 void select_comboa(int32_t clist)
7467 {
7468 current_comboalist=clist;
7469 int32_t tempcb=ComboBrush;
7470 ComboBrush=0;
7471 alias_cset_mod=0;
7472
7473 auto& curlist = comboaliaslist[current_comboalist];
7474 while(gui_mouse_b())
7475 {
7476 int32_t x=gui_mouse_x();
7477
7478 if(x<curlist.x)
7479 x=curlist.x;
7480
7481 if(x>curlist.x+(curlist.w*curlist.xscale)-1)
7482 x=curlist.x+(curlist.w*curlist.xscale)-1;
7483
7484 int32_t y=gui_mouse_y();
7485
7486 if(y<curlist.y)
7487 y=curlist.y;
7488
7489 if(y>curlist.y+(curlist.h*curlist.yscale)-1)
7490 y=curlist.y+(curlist.h*curlist.yscale)-1;
7491
7492 combo_apos=(((y-curlist.y)/curlist.yscale)*curlist.w)+((x-curlist.x)/curlist.xscale)+combo_alistpos[current_comboalist];
7493 custom_vsync();
7494 refresh(rALL);
7495 }
7496
7497 ComboBrush=tempcb;
7498 }
7499
7500 void select_combop(int32_t clist)
7501 {
7502 current_cpoollist=clist;
7503 int32_t tempcb=ComboBrush;
7504 ComboBrush=0;
7505
7506 auto& curlist = comboaliaslist[current_cpoollist];
7507 while(gui_mouse_b())
7508 {
7509 int32_t x=gui_mouse_x();
7510
7511 if(x<curlist.x) x=curlist.x;
7512
7513 if(x>curlist.x+(curlist.w*curlist.xscale)-1)
7514 x=curlist.x+(curlist.w*curlist.xscale)-1;
7515
7516 int32_t y=gui_mouse_y();
7517
7518 if(y<curlist.y) y=curlist.y;
7519
7520 if(y>curlist.y+(curlist.h*curlist.yscale)-1)
7521 y=curlist.y+(curlist.h*curlist.yscale)-1;
7522
7523 combo_pool_pos=(((y-curlist.y)/curlist.yscale)*curlist.w)+((x-curlist.x)/curlist.xscale)+combo_pool_listpos[current_cpoollist];
7524 custom_vsync();
7525 refresh(rALL);
7526 }
7527
7528 ComboBrush=tempcb;
7529 }
7530
7531 void select_autocombo(int32_t clist)
7532 {
7533 current_cautolist = clist;
7534 int32_t tempcb = ComboBrush;
7535 ComboBrush = 0;
7536
7537 auto& curlist = comboaliaslist[current_cautolist];
7538 while (gui_mouse_b())
7539 {
7540 int32_t x = gui_mouse_x();
7541
7542 if (x < curlist.x) x = curlist.x;
7543
7544 if (x > curlist.x + (curlist.w * curlist.xscale) - 1)
7545 x = curlist.x + (curlist.w * curlist.xscale) - 1;
7546
7547 int32_t y = gui_mouse_y();
7548
7549 if (y < curlist.y) y = curlist.y;
7550
7551 if (y > curlist.y + (curlist.h * curlist.yscale) - 1)
7552 y = curlist.y + (curlist.h * curlist.yscale) - 1;
7553
7554 combo_auto_pos = (((y - curlist.y) / curlist.yscale) * curlist.w) + ((x - curlist.x) / curlist.xscale) + combo_auto_listpos[current_cautolist];
7555 cauto_height = combo_autos[combo_auto_pos].getArg() + 1;
7556 custom_vsync();
7557 refresh(rALL);
7558 }
7559
7560 ComboBrush = tempcb;
7561 }
7562
7563 void update_combobrush()
7564 {
7565 clear_bitmap(brushbmp);
7566
7567 if(draw_mode==dm_alias)
7568 {
7569 //int32_t count=(combo_aliases[combo_apos].width+1)*(combo_aliases[combo_apos].height+1)*(comboa_lmasktotal(combo_aliases[combo_apos].layermask));
7570 for(int32_t z=0; z<=comboa_lmasktotal(combo_aliases[combo_apos].layermask); z++)
7571 {
7572 for(int32_t y=0; y<=combo_aliases[combo_apos].height; y++)
7573 {
7574 for(int32_t x=0; x<=combo_aliases[combo_apos].width; x++)
7575 {
7576 int32_t position = ((y*(combo_aliases[combo_apos].width+1))+x)+((combo_aliases[combo_apos].width+1)*(combo_aliases[combo_apos].height+1)*z);
7577
7578 if(combo_aliases[combo_apos].combos[position])
7579 {
7580 if(z==0)
7581 {
7582 putcombo(brushbmp,x<<4,y<<4,combo_aliases[combo_apos].combos[position],wrap(combo_aliases[combo_apos].csets[position]+alias_cset_mod, 0, 13));
7583 }
7584 else
7585 {
7586 overcombo(brushbmp,x<<4,y<<4,combo_aliases[combo_apos].combos[position],wrap(combo_aliases[combo_apos].csets[position]+alias_cset_mod, 0, 13));
7587 }
7588 }
7589 }
7590 }
7591 }
7592
7593 int xoff = 6, yoff = 6;
7594 if(FloatBrush) // Offset the floating pixels, so the 'x' appears centered on the combo still -Em
7595 {
7596 xoff += 2;
7597 yoff += 2;
7598 }
7599 if(alias_origin & 1) // Right-align
7600 xoff += combo_aliases[combo_apos].width*16;
7601 if(alias_origin & 2) // Bottom-align
7602 yoff += combo_aliases[combo_apos].height*16;
7603
7604 textprintf_shadowed_ex(brushbmp, get_zc_font(font_sfont), xoff, yoff, vc(15), vc(0), -1, "x");
7605 }
7606 else if(draw_mode != dm_cpool)
7607 {
7608 int32_t cid = combobrushoverride > -1 ? combobrushoverride : Combo;
7609 int32_t c = 0;
7610
7611 for(int32_t i=0; i<256; i++)
7612 {
7613 if(unsigned(cid+c) >= MAXCOMBOS) break;
7614 if(((i%COMBOS_PER_ROW)<BrushWidth)&&((i/COMBOS_PER_ROW)<BrushHeight))
7615 {
7616 put_combo(brushbmp,(i%COMBOS_PER_ROW)<<4,(i/COMBOS_PER_ROW)<<4,cid+c,CSet,Flags&(cFLAGS|cWALK),0);
7617 }
7618
7619 if(((cid+c)&3)==3)
7620 c+=48;
7621
7622 ++c;
7623
7624 if((i%COMBOS_PER_ROW)==(COMBOS_PER_ROW-1))
7625 c-=256;
7626 }
7627 }
7628 }
7629
7630 byte relational_source_grid[256]=
7631 {
7632 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
7633 16, 16, 17, 17, 18, 18, 19, 19, 16, 16, 17, 17, 18, 18, 19, 19,
7634 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 23, 23, 23, 23,
7635 24, 24, 24, 24, 25, 25, 25, 25, 24, 24, 24, 24, 25, 25, 25, 25,
7636 26, 27, 26, 27, 26, 27, 26, 27, 28, 29, 28, 29, 28, 29, 28, 29,
7637 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
7638 31, 31, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32,
7639 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
7640 34, 35, 36, 37, 34, 35, 36, 37, 34, 35, 36, 37, 34, 35, 36, 37,
7641 38, 38, 39, 39, 38, 38, 39, 39, 38, 38, 39, 39, 38, 38, 39, 39,
7642 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
7643 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
7644 42, 43, 42, 43, 42, 43, 42, 43, 42, 43, 42, 43, 42, 43, 42, 43,
7645 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44,
7646 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
7647 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46
7648 };
7649
7650 static void draw_autocombo(ComboPosition combo_pos, bool rclick, bool pressframe = false)
7651 {
7652 combo_auto &ca = combo_autos[combo_auto_pos];
7653 int screen = Map.getScreenForPosition(combo_pos);
7654 int pos = combo_pos.truncate();
7655
7656 if (ca.valid())
7657 {
7658 switch (ca.getType())
7659 {
7660 case AUTOCOMBO_BASIC:
7661 {
7662 AutoPattern::autopattern_basic ap(ca.getType(), CurrentLayer, screen, pos, &ca);
7663 if (rclick)
7664 ap.erase(screen, pos);
7665 else
7666 ap.execute(screen, pos);
7667 break;
7668 }
7669 case AUTOCOMBO_Z1:
7670 {
7671 AutoPattern::autopattern_flatmtn ap(ca.getType(), CurrentLayer, screen, pos, &ca);
7672 if (rclick)
7673 ap.erase(screen, pos);
7674 else
7675 ap.execute(screen, pos);
7676 break;
7677 }
7678 case AUTOCOMBO_FENCE:
7679 {
7680 AutoPattern::autopattern_fence ap(ca.getType(), CurrentLayer, screen, pos, &ca);
7681 if (rclick)
7682 ap.erase(screen, pos);
7683 else
7684 ap.execute(screen, pos);
7685 break;
7686 }
7687 case AUTOCOMBO_Z4:
7688 {
7689 AutoPattern::autopattern_cakemtn ap(ca.getType(), CurrentLayer, screen, pos, &ca, cauto_height);
7690 if (rclick)
7691 ap.erase(screen, pos);
7692 else
7693 ap.execute(screen, pos);
7694 break;
7695 }
7696 case AUTOCOMBO_RELATIONAL:
7697 {
7698 AutoPattern::autopattern_relational ap(ca.getType(), CurrentLayer, screen, pos, &ca);
7699 if (rclick)
7700 ap.erase(screen, pos);
7701 else
7702 ap.execute(screen, pos);
7703 break;
7704 }
7705 case AUTOCOMBO_DGNCARVE:
7706 {
7707 AutoPattern::autopattern_dungeoncarve ap(ca.getType(), CurrentLayer, screen, pos, &ca);
7708 if (rclick)
7709 ap.erase(screen, pos);
7710 else
7711 ap.execute(screen, pos);
7712 break;
7713 }
7714 case AUTOCOMBO_DOR:
7715 {
7716 AutoPattern::autopattern_dormtn ap(ca.getType(), CurrentLayer, screen, pos, &ca, cauto_height);
7717 if (rclick)
7718 ap.erase(screen, pos);
7719 else
7720 ap.execute(screen, pos);
7721 break;
7722 }
7723 case AUTOCOMBO_TILING:
7724 {
7725 if (pressframe && (key[KEY_LSHIFT] || key[KEY_RSHIFT]))
7726 {
7727 int32_t x = (screen % 16) * 16 + (pos % 16);
7728 int32_t y = (screen / 16) * 11 + (pos / 16);
7729 byte w = (ca.getArg() & 0xF) + 1;
7730 byte h = ((ca.getArg() >> 4) & 0xF) + 1;
7731 ca.setOffsets(x % w, y % h);
7732 }
7733 AutoPattern::autopattern_tiling ap(ca.getType(), CurrentLayer, screen, pos, &ca);
7734 if (rclick)
7735 ap.erase(screen, pos);
7736 else
7737 ap.execute(screen, pos);
7738 break;
7739 }
7740 case AUTOCOMBO_REPLACE:
7741 {
7742 AutoPattern::autopattern_replace ap(ca.getType(), CurrentLayer, screen, pos, &ca);
7743 if (rclick)
7744 ap.erase(screen, pos);
7745 else
7746 ap.execute(screen, pos);
7747 break;
7748 }
7749 case AUTOCOMBO_DENSEFOREST:
7750 {
7751 if (pressframe && (key[KEY_LSHIFT] || key[KEY_RSHIFT]))
7752 {
7753 int32_t x = (screen % 16) * 16 + (pos % 16);
7754 int32_t y = (screen / 16) * 11 + (pos / 16);
7755 ca.setOffsets(x % 2, y % 2);
7756 }
7757 AutoPattern::autopattern_denseforest ap(ca.getType(), CurrentLayer, screen, pos, &ca);
7758 if (rclick)
7759 ap.erase(screen, pos);
7760 else
7761 ap.execute(screen, pos);
7762 break;
7763 }
7764 case AUTOCOMBO_EXTEND:
7765 {
7766 if (CHECK_CTRL_CMD)
7767 break;
7768 AutoPattern::autopattern_extend ap(ca.getType(), CurrentLayer, screen, pos, &ca);
7769 if (rclick)
7770 ap.erase(screen, pos);
7771 else
7772 ap.execute(screen, pos);
7773 break;
7774 }
7775 }
7776 }
7777 else
7778 {
7779 ca.updateValid();
7780 if(!ca.valid())
7781 InfoDialog("Notice", "The autocombo you're trying to use is invalid. Reason:"
7782 + ca.getInvalidReason()).show();
7783 }
7784 }
7785
7786 static void draw_autocombo_command(ComboPosition combo_pos, int32_t cmd = 0, int32_t arg = 0)
7787 {
7788 combo_auto ca = combo_autos[combo_auto_pos];
7789 int screen = Map.getScreenForPosition(combo_pos);
7790 int pos = combo_pos.truncate();
7791
7792 if (ca.valid())
7793 {
7794 switch (ca.getType())
7795 {
7796 case AUTOCOMBO_FENCE:
7797 {
7798 AutoPattern::autopattern_fence ap(ca.getType(), CurrentLayer, screen, pos, &ca);
7799 ap.flip_all_connected(screen, pos, 2048);
7800 break;
7801 }
7802 case AUTOCOMBO_Z4:
7803 {
7804 AutoPattern::autopattern_cakemtn ap(ca.getType(), CurrentLayer, screen, pos, &ca, cauto_height);
7805 switch (cmd)
7806 {
7807 case 0: // Flip
7808 ap.flip_all_connected(screen, pos, 2048);
7809 break;
7810 case 1: // Grow
7811 ap.resize_connected(screen, pos, 2048, vbound(arg, 1, 9));
7812 break;
7813 }
7814 }
7815 }
7816 }
7817 }
7818
7819 static int32_t get_autocombo_floating_cid(ComboPosition combo_pos, bool clicked)
7820 {
7821 combo_auto& ca = combo_autos[combo_auto_pos];
7822 int screen = Map.getScreenForPosition(combo_pos);
7823 int pos = combo_pos.truncate();
7824 int cid = 0;
7825
7826 if (ca.valid() && Map.isValidPosition(mouse_combo_pos))
7827 {
7828 switch (ca.getType())
7829 {
7830 case AUTOCOMBO_BASIC:
7831 {
7832 AutoPattern::autopattern_basic ap(ca.getType(), CurrentLayer, screen, pos, &ca);
7833 cid = ap.get_floating_cid(screen, pos);
7834 break;
7835 }
7836
7837 case AUTOCOMBO_Z1:
7838 {
7839 AutoPattern::autopattern_flatmtn ap(ca.getType(), CurrentLayer, screen, pos, &ca);
7840 cid = ap.get_floating_cid(screen, pos);
7841 break;
7842 }
7843 case AUTOCOMBO_FENCE:
7844 {
7845 AutoPattern::autopattern_fence ap(ca.getType(), CurrentLayer, screen, pos, &ca);
7846 cid = ap.get_floating_cid(screen, pos);
7847 break;
7848 }
7849 case AUTOCOMBO_Z4:
7850 {
7851 AutoPattern::autopattern_cakemtn ap(ca.getType(), CurrentLayer, screen, pos, &ca, cauto_height);
7852 cid = ap.get_floating_cid(screen, pos);
7853 break;
7854 }
7855 case AUTOCOMBO_RELATIONAL:
7856 {
7857 AutoPattern::autopattern_relational ap(ca.getType(), CurrentLayer, screen, pos, &ca);
7858 cid = ap.get_floating_cid(screen, pos);
7859 break;
7860 }
7861 case AUTOCOMBO_DGNCARVE:
7862 {
7863 AutoPattern::autopattern_dungeoncarve ap(ca.getType(), CurrentLayer, screen, pos, &ca);
7864 cid = ap.get_floating_cid(screen, pos);
7865 break;
7866 }
7867 case AUTOCOMBO_DOR:
7868 {
7869 AutoPattern::autopattern_dormtn ap(ca.getType(), CurrentLayer, screen, pos, &ca, cauto_height);
7870 cid = ap.get_floating_cid(screen, pos);
7871 break;
7872 }
7873 case AUTOCOMBO_TILING:
7874 {
7875 std::pair<byte, byte> offs = ca.getOffsets();
7876 if (!clicked && (key[KEY_LSHIFT] || key[KEY_RSHIFT]))
7877 {
7878 int32_t x = (screen % 16) * 16 + (pos % 16);
7879 int32_t y = (screen / 16) * 11 + (pos / 16);
7880 byte w = (ca.getArg() & 0xF) + 1;
7881 byte h = ((ca.getArg() >> 4) & 0xF) + 1;
7882 offs.first = (x % w);
7883 offs.second = (y % h);
7884 }
7885 AutoPattern::autopattern_tiling ap(ca.getType(), CurrentLayer, screen, pos, &ca);
7886 cid = ap.get_floating_cid(screen, pos);
7887 break;
7888 }
7889 case AUTOCOMBO_REPLACE:
7890 {
7891 AutoPattern::autopattern_replace ap(ca.getType(), CurrentLayer, screen, pos, &ca);
7892 cid = ap.get_floating_cid(screen, pos);
7893 break;
7894 }
7895 case AUTOCOMBO_DENSEFOREST:
7896 {
7897 AutoPattern::autopattern_denseforest ap(ca.getType(), CurrentLayer, screen, pos, &ca);
7898 cid = ap.get_floating_cid(screen, pos);
7899 break;
7900 }
7901 case AUTOCOMBO_EXTEND:
7902 {
7903 AutoPattern::autopattern_extend ap(ca.getType(), CurrentLayer, screen, pos, &ca);
7904 cid = ap.get_floating_cid(screen, pos);
7905 break;
7906 }
7907 }
7908 }
7909 return cid;
7910 }
7911
7912 void change_autocombo_height(int32_t change)
7913 {
7914 bool can_change = false;
7915 if (draw_mode == dm_auto)
7916 {
7917 combo_auto ca = combo_autos[combo_auto_pos];
7918 switch (ca.getType())
7919 {
7920 case AUTOCOMBO_Z4:
7921 can_change = true;
7922 [[fallthrough]];
7923 case AUTOCOMBO_DOR:
7924 break;
7925 default:
7926 return;
7927 }
7928 }
7929 else
7930 return;
7931
7932 int32_t x = gui_mouse_x();
7933 int32_t y = gui_mouse_y();
7934 double startx = mapscreen_x + (showedges ? (16 * mapscreen_single_scale) : 0);
7935 double starty = mapscreen_y + (showedges ? (16 * mapscreen_single_scale) : 0);
7936 int32_t startxint = mapscreen_x + (showedges ? int32_t(16 * mapscreen_single_scale) : 0);
7937 int32_t startyint = mapscreen_y + (showedges ? int32_t(16 * mapscreen_single_scale) : 0);
7938 ComboPosition pos = get_mapscreen_mouse_combo_pos();
7939
7940 if (can_change && isinRect(x, y, startxint, startyint, int32_t(startx + (256 * mapscreen_single_scale) - 1), int32_t(starty + (176 * mapscreen_single_scale) - 1)))
7941 {
7942 Map.StartListCommand();
7943 draw_autocombo_command(pos, 1, cauto_height + change);
7944 Map.FinishListCommand();
7945 }
7946 cauto_height = vbound(cauto_height + change, 1, 9);
7947 }
7948
7949 void draw(bool justcset)
7950 {
7951 combo_pool const& pool = combo_pools[combo_pool_pos];
7952 if(draw_mode == dm_cpool && !pool.valid())
7953 return;
7954 saved=false;
7955
7956 refresh(rMAP+rSCRMAP);
7957 ComboPosition last_pos = {-1, -1};
7958
7959 Map.StartListCommand();
7960 bool pressframe = true;
7961 while(gui_mouse_b())
7962 {
7963 int32_t x=gui_mouse_x();
7964 int32_t y=gui_mouse_y();
7965 double startx=mapscreen_x+(showedges?(16*mapscreen_single_scale):0);
7966 double starty=mapscreen_y+(showedges?(16*mapscreen_single_scale):0);
7967 int32_t startxint=mapscreen_x+(showedges?int32_t(16*mapscreen_single_scale):0);
7968 int32_t startyint=mapscreen_y+(showedges?int32_t(16*mapscreen_single_scale):0);
7969 int num_combos_width = 16 * Map.getViewSize();
7970 int num_combos_height = 11 * Map.getViewSize();
7971
7972 if(isinRect(x,y,startxint,startyint,int32_t(startx+(256*mapscreen_screenunit_scale)-1),int32_t(starty+(176*mapscreen_screenunit_scale)-1)))
7973 {
7974 int32_t cxstart=(x-startx)/(16*mapscreen_single_scale);
7975 int32_t cystart=(y-starty)/(16*mapscreen_single_scale);
7976 ComboPosition combo_start = {cxstart, cystart};
7977 if (pressframe)
7978 {
7979 last_pos = combo_start;
7980 }
7981 else if (combo_start == last_pos)
7982 {
7983 custom_vsync();
7984 refresh(rALL);
7985 continue;
7986 }
7987 else if(draw_mode == dm_auto)
7988 {
7989 // TODO: support when zoomed out.
7990 if (combo_autos[combo_auto_pos].getType() == AUTOCOMBO_FENCE || combo_autos[combo_auto_pos].getType() == AUTOCOMBO_Z4)
7991 {
7992 // Don't allow moving the brush at anything but cardinal directions while in these modes
7993 bool did_diag = std::abs(combo_start.x - last_pos.x) == 1 && std::abs(combo_start.y - last_pos.y) == 1;
7994
7995 if (did_diag)
7996 {
7997 int32_t oldx = last_pos.x;
7998 int32_t oldy = last_pos.y;
7999 int32_t cx = (oldx * 16 * mapscreen_single_scale) + 8;
8000 int32_t cy = (oldy * 16 * mapscreen_single_scale) + 8;
8001 int32_t nx = x - startxint;
8002 int32_t ny = y - startyint;
8003 if (std::abs(nx - cx) < std::abs(ny - cy))
8004 {
8005 oldy = vbound(oldy + ((ny - cy) < 0 ? -1 : 1), 0, 11);
8006 }
8007 else
8008 {
8009 oldx = vbound(oldx + ((nx - cx) < 0 ? -1 : 1), 0, 15);
8010 }
8011 combo_start = {oldx, oldy};
8012 }
8013 }
8014 }
8015 last_pos = combo_start;
8016
8017 switch(draw_mode)
8018 {
8019 case dm_normal:
8020 {
8021 int32_t cc=Combo;
8022
8023 for(int32_t cy=0; cy+cystart<num_combos_height&&cy<BrushHeight; cy++)
8024 {
8025 for(int32_t cx=0; cx+cxstart<num_combos_width&&cx<BrushWidth; cx++)
8026 {
8027 auto pos = combo_start + ComboPosition{cx, cy};
8028 cc=Combo + cx + cy*4;
8029 Map.DoSetComboCommand(pos, justcset ? -1 : cc, CSet);
8030 }
8031 }
8032
8033 update_combobrush();
8034 }
8035 break;
8036 case dm_cpool:
8037 {
8038 int32_t cid = Combo;
8039 int8_t cs = CSet;
8040 pool.pick(cid,cs);
8041 Map.DoSetComboCommand(combo_start, justcset ? -1 : cid, cs);
8042
8043 update_combobrush();
8044 }
8045 break;
8046
8047 case dm_alias:
8048 {
8049 combo_alias *combo = &combo_aliases[combo_apos];
8050 if(!combo->layermask)
8051 {
8052 int32_t ox=0, oy=0;
8053
8054 switch(alias_origin)
8055 {
8056 case 0:
8057 ox=0;
8058 oy=0;
8059 break;
8060
8061 case 1:
8062 ox=(combo->width);
8063 oy=0;
8064 break;
8065
8066 case 2:
8067 ox=0;
8068 oy=(combo->height);
8069 break;
8070
8071 case 3:
8072 ox=(combo->width);
8073 oy=(combo->height);
8074 break;
8075 }
8076
8077 for(int32_t cy=0; cy-oy+cystart<num_combos_height&&cy<=combo->height; cy++)
8078 {
8079 for(int32_t cx=0; cx-ox+cxstart<num_combos_width&&cx<=combo->width; cx++)
8080 {
8081 if((cx+cxstart-ox>=0)&&(cy+cystart-oy>=0))
8082 {
8083 int32_t p=(cy*(combo->width+1))+cx;
8084
8085 if(combo->combos[p])
8086 {
8087 auto pos = combo_start + ComboPosition{cx - ox, cy - oy};
8088 Map.DoSetComboCommand(pos, combo->combos[p], wrap(combo->csets[p]+alias_cset_mod, 0, 13));
8089 }
8090 }
8091 }
8092 }
8093 }
8094 else
8095 {
8096 int32_t laypos = 0;
8097 int32_t ox=0, oy=0;
8098
8099 switch(alias_origin)
8100 {
8101 case 0:
8102 ox=0;
8103 oy=0;
8104 break;
8105
8106 case 1:
8107 ox=(combo->width);
8108 oy=0;
8109 break;
8110
8111 case 2:
8112 ox=0;
8113 oy=(combo->height);
8114 break;
8115
8116 case 3:
8117 ox=(combo->width);
8118 oy=(combo->height);
8119 break;
8120 }
8121
8122 for(int32_t cz=0; cz<7; cz++)
8123 {
8124 if (cz > 0 && !(combo->layermask & (1<<(cz-1))))
8125 continue;
8126
8127 if (cz > 0)
8128 laypos++;
8129
8130 for(int32_t cy=0; cy-oy+cystart<num_combos_height&&cy<=combo->height; cy++)
8131 {
8132 for(int32_t cx=0; cx-ox+cxstart<num_combos_width&&cx<=combo->width; cx++)
8133 {
8134 if((cx+cxstart-ox>=0)&&(cy+cystart-oy>=0))
8135 {
8136 int32_t p=((cy*(combo->width+1))+cx)+((combo->width+1)*(combo->height+1)*laypos);
8137
8138 if (combo->combos[p])
8139 {
8140 auto pos = combo_start + ComboPosition{cx - ox, cy - oy};
8141 if(cz > 0 && Map.Scr(pos)->layermap[cz - 1] == 0)
8142 continue;
8143 int prev = CurrentLayer;
8144 CurrentLayer = cz;
8145 Map.DoSetComboCommand(pos, combo->combos[p], wrap(combo->csets[p]+alias_cset_mod, 0, 13));
8146 CurrentLayer = prev;
8147 }
8148 }
8149 }
8150 }
8151 }
8152 }
8153
8154 break;
8155 }
8156
8157 case dm_auto:
8158 {
8159 draw_autocombo(combo_start, gui_mouse_b() & 2, pressframe);
8160
8161 combobrushoverride = get_autocombo_floating_cid(combo_start, true);
8162 update_combobrush();
8163 }
8164 }
8165 }
8166 pressframe = false;
8167
8168 custom_vsync();
8169 refresh(rALL);
8170 }
8171
8172 Map.FinishListCommand();
8173 if(AutoBrushRevert)
8174 {
8175 AutoBrushRevert = false;
8176 BrushWidth = 1;
8177 BrushHeight = 1;
8178 }
8179 }
8180
8181 static void replace(ComboPosition start)
8182 {
8183 int32_t cid = Combo;
8184 int8_t cs = CSet;
8185 combo_pool const& pool = combo_pools[combo_pool_pos];
8186 if(draw_mode == dm_cpool && !pool.valid())
8187 return;
8188
8189 int c = start.truncate();
8190 mapscr* scr = Map.Scr(start, CurrentLayer);
8191 if (!scr) return;
8192
8193 int num_combos_width = 16 * Map.getViewSize();
8194 int num_combos_height = 11 * Map.getViewSize();
8195 int targetcombo = scr->data[c];
8196 int targetcset = scr->cset[c];
8197
8198 saved = false;
8199 Map.StartListCommand();
8200 if(key[KEY_LSHIFT] || key[KEY_RSHIFT])
8201 {
8202 for (int x = 0; x < num_combos_width; x++)
8203 {
8204 for (int y = 0; y < num_combos_height; y++)
8205 {
8206 ComboPosition pos = {x, y};
8207 int c = pos.truncate();
8208 mapscr* scr = Map.Scr(pos, CurrentLayer);
8209 if (!scr)
8210 continue;
8211
8212 if ((scr->cset[c]) == targetcset)
8213 {
8214 if(draw_mode == dm_cpool)
8215 pool.pick(cid,cs);
8216 Map.DoSetComboCommand(pos, -1, cs);
8217 }
8218 }
8219 }
8220 }
8221 else
8222 {
8223 for (int x = 0; x < num_combos_width; x++)
8224 {
8225 for (int y = 0; y < num_combos_height; y++)
8226 {
8227 ComboPosition pos = {x, y};
8228 int c = pos.truncate();
8229 mapscr* scr = Map.Scr(pos, CurrentLayer);
8230 if (!scr)
8231 continue;
8232
8233 if(((scr->data[c])==targetcombo) &&
8234 ((scr->cset[c])==targetcset))
8235 {
8236 if(draw_mode == dm_cpool)
8237 pool.pick(cid,cs);
8238 Map.DoSetComboCommand(pos, cid, cs);
8239 }
8240 }
8241 }
8242 }
8243 Map.FinishListCommand();
8244
8245 refresh(rMAP);
8246 }
8247
8248 static void draw_block(ComboPosition start, int32_t w, int32_t h)
8249 {
8250 int32_t cid = Combo;
8251 int8_t cs = CSet;
8252 if(draw_mode == dm_cpool)
8253 {
8254 combo_pool const& pool = combo_pools[combo_pool_pos];
8255 if(!pool.pick(cid,cs)) return;
8256 }
8257
8258 mapscr* scr = Map.Scr(start, CurrentLayer);
8259 if (!scr) return;
8260
8261 saved = false;
8262 Map.StartListCommand();
8263 for (int32_t y=0; y < h && y < 11*Map.getViewSize(); y++)
8264 for (int32_t x=0; x < w && x < 16*Map.getViewSize(); x++)
8265 {
8266 Map.DoSetComboCommand(start + ComboPosition{x, y}, cid+(y*4)+x, cs);
8267 }
8268
8269 Map.FinishListCommand();
8270 refresh(rMAP+rSCRMAP);
8271 }
8272
8273 static std::vector<ComboPosition> flood_filler(ComboPosition start_pos, bool allow_diagonal, std::function<bool(ComboPosition)> check)
8274 {
8275 std::vector<ComboPosition> seen, queue;
8276
8277 queue.push_back(start_pos);
8278 while (!queue.empty())
8279 {
8280 ComboPosition pos = queue.back();
8281 queue.pop_back();
8282 seen.push_back(pos);
8283
8284 ComboPosition pos2;
8285 #define FLOOD_FILLER_CHECK(dx, dy)\
8286 pos2 = pos + ComboPosition{dx, dy};\
8287 if (std::find(seen.begin(), seen.end(), pos2) == seen.end() && check(pos2))\
8288 queue.push_back(pos2);
8289
8290 FLOOD_FILLER_CHECK(0, 1);
8291 FLOOD_FILLER_CHECK(0, -1);
8292 FLOOD_FILLER_CHECK(1, 0);
8293 FLOOD_FILLER_CHECK(-1, 0);
8294
8295 if (allow_diagonal)
8296 {
8297 FLOOD_FILLER_CHECK(1, 1);
8298 FLOOD_FILLER_CHECK(1, -1);
8299 FLOOD_FILLER_CHECK(-1, 1);
8300 FLOOD_FILLER_CHECK(-1, -1);
8301 }
8302
8303 #undef FLOOD_FILLER_CHECK
8304 }
8305
8306 return seen;
8307 }
8308
8309 static void fill(int32_t targetcombo, int32_t targetcset, ComboPosition start_pos, bool allow_diagonal, bool only_cset)
8310 {
8311 bool rclick = gui_mouse_b() & 2;
8312 bool ignored_combo = false;
8313
8314 mapscr* scr = Map.ScrMakeValid(start_pos, CurrentLayer);
8315 if (!scr)
8316 return;
8317
8318 int num_combos_width = 16 * Map.getViewSize();
8319 int num_combos_height = 11 * Map.getViewSize();
8320
8321 auto combo_positions = flood_filler(start_pos, allow_diagonal, [&](ComboPosition pos){
8322 if (pos.x < 0 || pos.y < 0 || pos.x >= num_combos_width || pos.y >= num_combos_height)
8323 return false;
8324
8325 mapscr* scr = Map.Scr(pos, CurrentLayer);
8326 if (!scr || !scr->is_valid())
8327 return false;
8328
8329 int cid = scr->data[pos.truncate()];
8330 int cset = scr->cset[pos.truncate()];
8331
8332 if (draw_mode == dm_auto)
8333 {
8334 combo_auto const& cauto = combo_autos[combo_auto_pos];
8335
8336 ignored_combo = cauto.isIgnoredCombo(cid);
8337 if (rclick)
8338 {
8339 if (cauto.containsCombo(targetcombo))
8340 {
8341 if (!cauto.containsCombo(cid))
8342 return false;
8343 if (cauto.getType() == AUTOCOMBO_REPLACE && ignored_combo)
8344 return false;
8345 }
8346 else
8347 return false;
8348 }
8349 else
8350 {
8351 if (cid != targetcombo && !ignored_combo)
8352 return false;
8353 if (cauto.getType() == AUTOCOMBO_REPLACE && !ignored_combo)
8354 return false;
8355 }
8356
8357 if (cset != targetcset && !ignored_combo)
8358 return false;
8359 }
8360 else
8361 {
8362 if(!only_cset)
8363 {
8364 if (cid != targetcombo)
8365 return false;
8366 }
8367
8368 if (cset != targetcset)
8369 return false;
8370 }
8371
8372 return true;
8373 });
8374
8375 for (auto& pos : combo_positions)
8376 {
8377 int32_t cid = Combo;
8378 int8_t cs = CSet;
8379
8380 if (draw_mode == dm_cpool)
8381 {
8382 combo_pool const& pool = combo_pools[combo_pool_pos];
8383 if (!pool.pick(cid, cs)) continue;
8384 }
8385 else if (draw_mode == dm_auto)
8386 {
8387 combo_auto const& cauto = combo_autos[combo_auto_pos];
8388 if (!cauto.valid())
8389 continue;
8390 if (!rclick && (cauto.containsCombo(targetcombo) && !ignored_combo))
8391 continue;
8392 if (rclick && cauto.getEraseCombo() == targetcombo)
8393 continue;
8394 }
8395
8396 if (draw_mode == dm_auto)
8397 draw_autocombo(pos, rclick);
8398 else
8399 Map.DoSetComboCommand(pos, only_cset ? -1 : cid, cs);
8400 }
8401 }
8402
8403 static void fill_flag(int32_t targetflag, ComboPosition start_pos, bool allow_diagonal)
8404 {
8405 mapscr* scr = Map.ScrMakeValid(start_pos, CurrentLayer);
8406 if (!scr)
8407 return;
8408
8409 int num_combos_width = 16 * Map.getViewSize();
8410 int num_combos_height = 11 * Map.getViewSize();
8411
8412 auto combo_positions = flood_filler(start_pos, allow_diagonal, [&](ComboPosition pos){
8413 if (pos.x < 0 || pos.y < 0 || pos.x >= num_combos_width || pos.y >= num_combos_height)
8414 return false;
8415
8416 mapscr* scr = Map.Scr(pos, CurrentLayer);
8417 if (!scr || !scr->is_valid())
8418 return false;
8419
8420 if (scr->sflag[pos.truncate()] != targetflag)
8421 return false;
8422
8423 return true;
8424 });
8425
8426 for (auto& pos : combo_positions)
8427 Map.DoSetFlagCommand(pos, Flag);
8428 }
8429
8430 static void fill2(int32_t targetcombo, int32_t targetcset, ComboPosition pos, int32_t dir, int32_t diagonal, bool only_cset)
8431 {
8432 mapscr* scr = Map.Scr(pos, CurrentLayer);
8433 if (!scr || !scr->is_valid())
8434 return;
8435
8436 int cid = scr->data[pos.truncate()];
8437 int cset = scr->cset[pos.truncate()];
8438
8439 if (!only_cset)
8440 {
8441 if (cid == targetcombo)
8442 return;
8443 }
8444
8445 if (cset == targetcset)
8446 return;
8447
8448 cid = Combo;
8449 int8_t cs = CSet;
8450 if(draw_mode == dm_cpool)
8451 {
8452 combo_pool const& pool = combo_pools[combo_pool_pos];
8453 if(!pool.pick(cid,cs)) return;
8454 }
8455
8456 Map.DoSetComboCommand(pos, only_cset ? -1 : cid, cs);
8457
8458 int num_combos_width = 16 * Map.getViewSize();
8459 int num_combos_height = 11 * Map.getViewSize();
8460
8461 if (pos.y > 0 && dir != down)
8462 fill2(targetcombo, targetcset, pos + ComboPosition{0, -1}, up, diagonal, only_cset);
8463 if (pos.y < num_combos_height-1 && dir != up)
8464 fill2(targetcombo, targetcset, pos + ComboPosition{0, 1}, down, diagonal, only_cset);
8465 if (pos.x > 0 && dir != right)
8466 fill2(targetcombo, targetcset, pos + ComboPosition{-1, 0}, left, diagonal, only_cset);
8467 if (pos.x < num_combos_width-1 && dir != left)
8468 fill2(targetcombo, targetcset, pos + ComboPosition{1, 0}, right, diagonal, only_cset);
8469
8470 if (diagonal == 1)
8471 {
8472 if (pos.y > 0 && pos.x > 0 && dir != r_down)
8473 fill2(targetcombo, targetcset, pos + ComboPosition{-1, -1}, l_up, diagonal, only_cset);
8474 if (pos.y < num_combos_height-1 && pos.x < num_combos_width-1 && dir != l_up)
8475 fill2(targetcombo, targetcset, pos + ComboPosition{1, 1}, r_down, diagonal, only_cset);
8476 if (pos.x > 0 && pos.y < num_combos_height-1 && dir != r_up)
8477 fill2(targetcombo, targetcset, pos + ComboPosition{-1, 1}, l_down, diagonal, only_cset);
8478 if (pos.x < num_combos_width-1 && pos.y > 0 && dir != l_down)
8479 fill2(targetcombo, targetcset, pos + ComboPosition{1, -1}, r_up, diagonal, only_cset);
8480 }
8481 }
8482
8483
8484 enum SnapMode
8485 {
8486 SNAP_NONE, SNAP_HALF, SNAP_WHOLE
8487 };
8488 static void snap_xy(int& x, int& y, SnapMode mode, roundType rounding, optional<int> max_x = nullopt, optional<int> max_y = nullopt)
8489 {
8490 if(mode == SNAP_NONE)
8491 {
8492 if(max_x) x = vbound(x,*max_x,0);
8493 if(max_y) y = vbound(y,*max_y,0);
8494 return;
8495 }
8496 int xoff = 0, yoff = 0;
8497 switch(rounding)
8498 {
8499 case ROUND_TO_0:
8500 rounding = ROUND_DOWN;
8501 break;
8502 case ROUND_AWAY_0:
8503 rounding = ROUND_UP;
8504 break;
8505 }
8506 int r = 0;
8507 switch(mode)
8508 {
8509 case SNAP_HALF:
8510 r = 8;
8511 break;
8512 case SNAP_WHOLE:
8513 r = 16;
8514 break;
8515 }
8516 assert(r > 0);
8517 // r must be a power of 2, for bitwise reasons
8518 switch(rounding)
8519 {
8520 case ROUND_DOWN:
8521 break;
8522 case ROUND_UP:
8523 xoff = ((x & (r-1)) ? r : 0);
8524 yoff = ((y & (r-1)) ? r : 0);
8525 break;
8526 case ROUND_NEAREST:
8527 xoff = ((x & (r-1)) >= (r/2) ? r : 0);
8528 yoff = ((y & (r-1)) >= (r/2) ? r : 0);
8529 break;
8530 }
8531 x = (x & ~(r-1)) + xoff;
8532 y = (y & ~(r-1)) + yoff;
8533 if(max_x && x >= *max_x) x = *max_x-r;
8534 else if(max_x && x < 0) x = 0;
8535 if(max_y && y >= *max_y) y = *max_y-r;
8536 else if(max_y && y < 0) y = 0;
8537 }
8538
8539 static void doxypos(byte &px2, byte &py2, int32_t color, SnapMode snap_mode,
8540 SnapMode shift_mode, bool immediately, int32_t cursoroffx,
8541 int32_t cursoroffy, int32_t iconw, int32_t iconh)
8542 {
8543 int32_t tempcb=ComboBrush;
8544 ComboBrush=0;
8545 MouseSprite::set(ZQM_POINT_BOX);
8546
8547 int viz_off_x = (active_visible_screen ? active_visible_screen->dx * 256 : 0);
8548 int viz_off_y = (active_visible_screen ? active_visible_screen->dy * 176 : 0);
8549
8550 int32_t oldpx=px2, oldpy=py2;
8551 int32_t startxint=mapscreen_x+(showedges?int32_t(16*mapscreen_single_scale):0);
8552 int32_t startyint=mapscreen_y+(showedges?int32_t(16*mapscreen_single_scale):0);
8553 showxypos_x=px2 + viz_off_x;
8554 showxypos_y=py2 + viz_off_y;
8555 showxypos_w=iconw;
8556 showxypos_h=iconh;
8557 showxypos_color=vc(color);
8558 showxypos_icon=!showxypos_dummy;
8559 bool canedit=false;
8560 bool done=false;
8561
8562 clear_tooltip();
8563
8564 while(!done && (!(gui_mouse_b()&2) || immediately))
8565 {
8566 if(!gui_mouse_b() || immediately)
8567 {
8568 canedit=true;
8569 }
8570
8571 // TODO: would be nice if these bounds were based on the individual screen.
8572 if(canedit && gui_mouse_b()==1 && isinRect(gui_mouse_x(),gui_mouse_y(),startxint,startyint,(startxint+(256*mapscreen_screenunit_scale)-1),(startyint+(176*mapscreen_screenunit_scale)-1)))
8573 {
8574 set_mouse_range(startxint,startyint,int32_t(startxint+(256*mapscreen_screenunit_scale)-1),int32_t(startyint+(176*mapscreen_screenunit_scale)-1));
8575
8576 double offx = 0, offy = 0;
8577 roundType rounding = ROUND_DOWN;
8578 if(DragCenterOfSquares)
8579 {
8580 offx -= iconw*mapscreen_single_scale/2;
8581 offy -= iconh*mapscreen_single_scale/2;
8582 rounding = ROUND_NEAREST;
8583 }
8584 int32_t x, y;
8585 do
8586 {
8587 x=int32_t((gui_mouse_x()-startxint+offx)/mapscreen_single_scale)-cursoroffx;
8588 y=int32_t((gui_mouse_y()-startyint+offy)/mapscreen_single_scale)-cursoroffy;
8589 showxypos_cursor_icon=true;
8590 showxypos_cursor_color = showxypos_color;
8591 auto _mode = (key[KEY_LSHIFT] || key[KEY_RSHIFT]) ? shift_mode : snap_mode;
8592 showxypos_cursor_x = x-viz_off_x;
8593 showxypos_cursor_y = y-viz_off_y;
8594 snap_xy(showxypos_cursor_x, showxypos_cursor_y, _mode, rounding, 256, 176);
8595 showxypos_cursor_x += viz_off_x;
8596 showxypos_cursor_y += viz_off_y;
8597 custom_vsync();
8598 refresh(rALL | rNOCURSOR);
8599 int32_t xpos[2], ypos[2];
8600 int32_t x1,y1,x2,y2;
8601
8602 char b1[200] = {0};
8603 char b2[200] = {0};
8604 if(showxypos_dummy)
8605 strcpy(b1, "DUMMY MEASURING");
8606 else sprintf(b1, "%d %d",oldpx,oldpy);
8607 sprintf(b2, "%d %d (%d %d)",x-viz_off_x,y-viz_off_y,showxypos_cursor_x-viz_off_x,showxypos_cursor_y-viz_off_y);
8608
8609 int len[2] = {text_length(font,b1),text_length(font,b2)};
8610
8611 if(is_compact)
8612 {
8613 xpos[0] = 4;
8614 ypos[0] = layer_panel.y - 21;
8615 xpos[1] = xpos[0];
8616 ypos[1] = ypos[0]+10;
8617 }
8618 else
8619 {
8620 xpos[0] = 450;
8621 ypos[0] = 405;
8622 xpos[1] = xpos[0];
8623 ypos[1] = ypos[0]+10;
8624 }
8625
8626 x1 = xpos[0];
8627 y1 = ypos[0];
8628 x2 = xpos[0];
8629 y2 = ypos[0];
8630 for(auto q = 0; q < 2; ++q)
8631 {
8632 if(xpos[q] < x1)
8633 x1 = xpos[q];
8634 if(ypos[q] < y1)
8635 y1 = ypos[q];
8636 if(ypos[q] > y2)
8637 y2 = ypos[q];
8638 if(xpos[q] + len[q] > x2)
8639 x2 = xpos[q] + len[q];
8640 }
8641 x1 -= 4;
8642 y1 -= 2;
8643 y2 += text_height(font)+2;
8644
8645 auto minx = zc_min(xpos[0],xpos[1]);
8646 auto miny = zc_min(ypos[0],ypos[1]);
8647 rectfill(screen,x1,y1,x2,y2,vc(0));
8648 textprintf_ex(screen,font,xpos[0],ypos[0],vc(15),vc(0),"%s",b1);
8649 textprintf_ex(screen,font,xpos[1],ypos[1],vc(15),vc(0),"%s",b2);
8650 update_hw_screen();
8651 }
8652 while(gui_mouse_b()==1);
8653
8654 if(gui_mouse_b()==0)
8655 {
8656 auto _mode = (key[KEY_LSHIFT] || key[KEY_RSHIFT]) ? shift_mode : snap_mode;
8657 int x2 = vbound(x-viz_off_x,0,255);
8658 int y2 = vbound(y-viz_off_y,0,175);
8659 snap_xy(x2, y2, _mode, rounding, 256, 176);
8660 px2=byte(x2);
8661 py2=byte(y2);
8662 }
8663
8664 set_mouse_range(0,0,zq_screen_w-1,zq_screen_h-1);
8665 done=true;
8666 }
8667
8668 if(keypressed())
8669 {
8670 switch(readkey()>>8)
8671 {
8672 case KEY_ESC:
8673 case KEY_ENTER:
8674 goto finished;
8675 }
8676 }
8677
8678 custom_vsync();
8679 refresh(rALL | rNOCURSOR);
8680 }
8681
8682 finished:
8683 MouseSprite::set(ZQM_NORMAL);
8684 refresh(rMAP+rMENU);
8685
8686 while(gui_mouse_b())
8687 {
8688 /* do nothing */
8689 rest(1);
8690 }
8691
8692 showxypos_x=-1000;
8693 showxypos_y=-1000;
8694 showxypos_color=-1000;
8695 showxypos_ffc=-1000;
8696 showxypos_icon=false;
8697 showxypos_cursor_x=-1000;
8698 showxypos_cursor_y=-1000;
8699 showxypos_cursor_icon=false;
8700 showxypos_cursor_color=-1000;
8701 showxypos_dummy=false;
8702
8703 if(px2!=oldpx||py2!=oldpy)
8704 {
8705 saved=false;
8706 }
8707
8708 ComboBrush=tempcb;
8709 }
8710 static void doxypos(byte &px2,byte &py2,int32_t color,SnapMode snap_mode, optional<SnapMode> shift_mode = nullopt)
8711 {
8712 doxypos(px2,py2,color,snap_mode,shift_mode ? *shift_mode : snap_mode,false,0,0,16,16);
8713 }
8714
8715 bool placing_flags = false;
8716 void doflags()
8717 {
8718 placing_flags = true;
8719 int of=Flags;
8720 Flags=cFLAGS;
8721 refresh(rMAP | rNOCURSOR);
8722
8723 bool canedit=false;
8724 bool didShift = false;
8725 int tFlag = Flag;
8726 while(!(gui_mouse_b()&2) && !handle_close_btn_quit())
8727 {
8728 int x=gui_mouse_x();
8729 int y=gui_mouse_y();
8730 double startx=mapscreen_x+(showedges?(16*mapscreen_single_scale):0);
8731 double starty=mapscreen_y+(showedges?(16*mapscreen_single_scale):0);
8732 int startxint=mapscreen_x+(showedges?int(16*mapscreen_single_scale):0);
8733 int startyint=mapscreen_y+(showedges?int(16*mapscreen_single_scale):0);
8734 int cx=(x-startxint)/int(16*mapscreen_single_scale);
8735 int cy=(y-startyint)/int(16*mapscreen_single_scale);
8736 ComboPosition combo_pos = {cx, cy};
8737 int c = combo_pos.truncate();
8738
8739 if(!gui_mouse_b())
8740 canedit=true;
8741 bool shift = key[KEY_LSHIFT] || key[KEY_RSHIFT];
8742
8743 if(canedit && gui_mouse_b()==1 && isinRect(x,y,startxint,startyint,int(startx+(256*mapscreen_screenunit_scale)-1),int(starty+(176*mapscreen_screenunit_scale)-1)))
8744 {
8745 mapscr* cur_scr = Map.Scr(combo_pos, CurrentLayer);
8746 if (!cur_scr) continue;
8747
8748 Map.setCurrScr(Map.getScreenForPosition(combo_pos));
8749
8750 if(key[KEY_ALT]||key[KEY_ALTGR])
8751 Flag = cur_scr->sflag[c];
8752 else
8753 {
8754 saved=false;
8755 int tflag = Flag;
8756 if(shift)
8757 Flag = mfNONE;
8758 if(CurrentLayer!=0)
8759 {
8760 // Notify if they are using a flag that doesn't work on this layer.
8761 if(!skipLayerWarning && ((Flag >= mfTRAP_H && Flag < mfPUSHD) || (Flag == mfFAIRY) || (Flag == mfMAGICFAIRY)
8762 || (Flag == mfALLFAIRY) || (Flag == mfRAFT) || (Flag == mfRAFT_BRANCH)
8763 || (Flag == mfDIVE_ITEM) || (Flag == mfARMOS_SECRET) || (Flag == mfNOENEMY)
8764 || (Flag == mfZELDA)))
8765 {
8766 InfoDialog("Notice","You are currently working on layer "
8767 +to_string(CurrentLayer)
8768 +". This combo flag does not function on layers above '0'.").show();
8769 }
8770 if(!skipLayerWarning && CurrentLayer > 2 &&
8771 ((Flag == mfBLOCKHOLE) || (Flag >= mfPUSHD && Flag < mfNOBLOCKS)
8772 || (Flag == mfPUSHUD) || (Flag == mfPUSH4)))
8773 {
8774 InfoDialog("Notice","You are currently working on layer "
8775 +to_string(CurrentLayer)
8776 +". This combo flag does not function on layers above '2'.").show();
8777 }
8778 }
8779 if(CHECK_CTRL_CMD)
8780 {
8781 switch(fill_type)
8782 {
8783 case 0:
8784 flood_flag();
8785 break;
8786
8787 case 1:
8788 case 3:
8789 fill_4_flag();
8790 break;
8791
8792 case 2:
8793 case 4:
8794 fill_8_flag();
8795 break;
8796 }
8797 }
8798 else
8799 {
8800 Map.DoSetFlagCommand(combo_pos, Flag);
8801 }
8802 Flag = tflag;
8803 }
8804 }
8805
8806 if(mouse_z)
8807 {
8808 for(int i=0; i<abs(mouse_z); ++i)
8809 {
8810 if(mouse_z>0)
8811 onIncreaseFlag();
8812 else
8813 onDecreaseFlag();
8814 }
8815
8816 position_mouse_z(0);
8817 }
8818
8819 if(keypressed())
8820 {
8821 int k = readkey();
8822 switch(k>>8)
8823 {
8824 case KEY_ESC:
8825 case KEY_ENTER:
8826 goto finished;
8827 }
8828 object_message(dialogs+1, MSG_XCHAR, k);
8829 Flags=cFLAGS;
8830 }
8831
8832 MouseSprite::set(ZQM_FLAG_0+(shift?0:Flag%16));
8833
8834 refresh(rALL | rCLEAR | rNOCURSOR);
8835 custom_vsync();
8836 }
8837
8838 finished:
8839 Flags=of;
8840 placing_flags = false;
8841 MouseSprite::set(ZQM_NORMAL);
8842 refresh(rMAP+rMENU);
8843
8844 while(gui_mouse_b())
8845 {
8846 /* do nothing */
8847 rest(1);
8848 }
8849 }
8850
8851 // Drag FFCs around
8852 static void moveffc(int i, int cx, int cy)
8853 {
8854 mapscr* scr = active_visible_screen->scr;
8855 int screen = active_visible_screen->screen;
8856
8857 int32_t ffx = vbound(scr->ffcs[i].x.getFloor(),0,240);
8858 int32_t ffy = vbound(scr->ffcs[i].y.getFloor(),0,160);
8859 int32_t offx = ffx, offy = ffy;
8860 showxypos_ffc = i;
8861 doxypos((byte&)ffx,(byte&)ffy,15,SNAP_HALF,SNAP_NONE,true,0,0,(scr->ffTileWidth(i)*16),(scr->ffTileHeight(i)*16));
8862 if(ffx > 240) ffx = 240;
8863 if(ffy > 160) ffy = 160;
8864 if((ffx != offx) || (ffy != offy))
8865 {
8866 auto set_ffc_data = set_ffc_command::create_data(scr->ffcs[i]);
8867 set_ffc_data.x = ffx;
8868 set_ffc_data.y = ffy;
8869 Map.DoSetFFCCommand(Map.getCurrMap(), screen, i, set_ffc_data);
8870 saved = false;
8871 }
8872 }
8873
8874 void set_brush_width(int32_t width);
8875 void set_brush_height(int32_t height);
8876
8877 int32_t set_brush_width_1()
8878 {
8879 set_brush_width(1);
8880 return D_O_K;
8881 }
8882 int32_t set_brush_width_2()
8883 {
8884 set_brush_width(2);
8885 return D_O_K;
8886 }
8887 int32_t set_brush_width_3()
8888 {
8889 set_brush_width(3);
8890 return D_O_K;
8891 }
8892 int32_t set_brush_width_4()
8893 {
8894 set_brush_width(4);
8895 return D_O_K;
8896 }
8897 int32_t set_brush_width_5()
8898 {
8899 set_brush_width(5);
8900 return D_O_K;
8901 }
8902 int32_t set_brush_width_6()
8903 {
8904 set_brush_width(6);
8905 return D_O_K;
8906 }
8907 int32_t set_brush_width_7()
8908 {
8909 set_brush_width(7);
8910 return D_O_K;
8911 }
8912 int32_t set_brush_width_8()
8913 {
8914 set_brush_width(8);
8915 return D_O_K;
8916 }
8917 int32_t set_brush_width_9()
8918 {
8919 set_brush_width(9);
8920 return D_O_K;
8921 }
8922 int32_t set_brush_width_10()
8923 {
8924 set_brush_width(10);
8925 return D_O_K;
8926 }
8927 int32_t set_brush_width_11()
8928 {
8929 set_brush_width(11);
8930 return D_O_K;
8931 }
8932 int32_t set_brush_width_12()
8933 {
8934 set_brush_width(12);
8935 return D_O_K;
8936 }
8937 int32_t set_brush_width_13()
8938 {
8939 set_brush_width(13);
8940 return D_O_K;
8941 }
8942 int32_t set_brush_width_14()
8943 {
8944 set_brush_width(14);
8945 return D_O_K;
8946 }
8947 int32_t set_brush_width_15()
8948 {
8949 set_brush_width(15);
8950 return D_O_K;
8951 }
8952 int32_t set_brush_width_16()
8953 {
8954 set_brush_width(16);
8955 return D_O_K;
8956 }
8957
8958 int32_t set_brush_height_1()
8959 {
8960 set_brush_height(1);
8961 return D_O_K;
8962 }
8963 int32_t set_brush_height_2()
8964 {
8965 set_brush_height(2);
8966 return D_O_K;
8967 }
8968 int32_t set_brush_height_3()
8969 {
8970 set_brush_height(3);
8971 return D_O_K;
8972 }
8973 int32_t set_brush_height_4()
8974 {
8975 set_brush_height(4);
8976 return D_O_K;
8977 }
8978 int32_t set_brush_height_5()
8979 {
8980 set_brush_height(5);
8981 return D_O_K;
8982 }
8983 int32_t set_brush_height_6()
8984 {
8985 set_brush_height(6);
8986 return D_O_K;
8987 }
8988 int32_t set_brush_height_7()
8989 {
8990 set_brush_height(7);
8991 return D_O_K;
8992 }
8993 int32_t set_brush_height_8()
8994 {
8995 set_brush_height(8);
8996 return D_O_K;
8997 }
8998 int32_t set_brush_height_9()
8999 {
9000 set_brush_height(9);
9001 return D_O_K;
9002 }
9003 int32_t set_brush_height_10()
9004 {
9005 set_brush_height(10);
9006 return D_O_K;
9007 }
9008 int32_t set_brush_height_11()
9009 {
9010 set_brush_height(11);
9011 return D_O_K;
9012 }
9013
9014
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu brush_width_menu
9015 204 {
9016
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "1", set_brush_width_1 },
9017
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "2", set_brush_width_2 },
9018
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "3", set_brush_width_3 },
9019
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "4", set_brush_width_4 },
9020
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "5", set_brush_width_5 },
9021
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "6", set_brush_width_6 },
9022
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "7", set_brush_width_7 },
9023
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "8", set_brush_width_8 },
9024
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "9", set_brush_width_9 },
9025
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "10", set_brush_width_10 },
9026
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "11", set_brush_width_11 },
9027
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "12", set_brush_width_12 },
9028
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "13", set_brush_width_13 },
9029
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "14", set_brush_width_14 },
9030
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "15", set_brush_width_15 },
9031
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "16", set_brush_width_16 },
9032 };
9033
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu brush_height_menu
9034 144 {
9035
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "1", set_brush_height_1 },
9036
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "2", set_brush_height_2 },
9037
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "3", set_brush_height_3 },
9038
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "4", set_brush_height_4 },
9039
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "5", set_brush_height_5 },
9040
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "6", set_brush_height_6 },
9041
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "7", set_brush_height_7 },
9042
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "8", set_brush_height_8 },
9043
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "9", set_brush_height_9 },
9044
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "10", set_brush_height_10 },
9045
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "11", set_brush_height_11 },
9046 };
9047
9048 int toggle_autobrush();
9049 int toggle_combobrush();
9050 int toggle_floatbrush();
9051 enum
9052 {
9053 MENUID_BRUSH_AUTOBRUSH,
9054 MENUID_BRUSH_WIDTH,
9055 MENUID_BRUSH_HEIGHT,
9056 MENUID_BRUSH_COMBOBRUSH,
9057 MENUID_BRUSH_FLOATBRUSH,
9058 };
9059
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu brush_menu
9060 72 {
9061
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "AutoBrush", toggle_autobrush, MENUID_BRUSH_AUTOBRUSH },
9062
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Brush Width ", &brush_width_menu, MENUID_BRUSH_WIDTH },
9063
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Brush Height ", &brush_height_menu, MENUID_BRUSH_HEIGHT },
9064
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "ComboBrush", toggle_combobrush, MENUID_BRUSH_COMBOBRUSH },
9065
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "FloatBrush", toggle_floatbrush, MENUID_BRUSH_FLOATBRUSH },
9066 };
9067 int toggle_autobrush()
9068 {
9069 AutoBrush = AutoBrush ? 0 : 1;
9070 BrushWidth = BrushHeight = 1;
9071 brush_menu.select_uid(MENUID_BRUSH_AUTOBRUSH, AutoBrush);
9072 brush_menu.disable_uid(MENUID_BRUSH_WIDTH, AutoBrush);
9073 brush_menu.disable_uid(MENUID_BRUSH_HEIGHT, AutoBrush);
9074 zc_set_config("zquest","autobrush",AutoBrush);
9075 return D_O_K;
9076 }
9077 int toggle_combobrush()
9078 {
9079 ComboBrush = ComboBrush ? 0 : 1;
9080 brush_menu.select_uid(MENUID_BRUSH_COMBOBRUSH, ComboBrush);
9081 zc_set_config("zquest","combo_brush",ComboBrush);
9082 return D_O_K;
9083 }
9084 int toggle_floatbrush()
9085 {
9086 FloatBrush = FloatBrush ? 0 : 1;
9087 brush_menu.select_uid(MENUID_BRUSH_FLOATBRUSH, FloatBrush);
9088 zc_set_config("zquest","float_brush",FloatBrush);
9089 return D_O_K;
9090 }
9091
9092 int32_t set_flood();
9093 int32_t set_fill_4();
9094 int32_t set_fill_8();
9095 int32_t set_fill2_4();
9096 int32_t set_fill2_8();
9097
9098 // Sets every combo.
9099 void flood()
9100 {
9101 ComboPosition pos = get_mapscreen_mouse_combo_pos();
9102 mapscr* scr = Map.ScrMakeValid(pos, CurrentLayer);
9103 if (!scr || !scr->is_valid())
9104 return;
9105
9106 saved=false;
9107
9108 bool include_combos = !(key[KEY_LSHIFT]||key[KEY_RSHIFT]);
9109
9110 int num_combos_width = 16 * Map.getViewSize();
9111 int num_combos_height = 11 * Map.getViewSize();
9112
9113 Map.StartListCommand();
9114 for (int x = 0; x < num_combos_width; x++)
9115 {
9116 for (int y = 0; y < num_combos_height; y++)
9117 {
9118 ComboPosition pos = {x, y};
9119 mapscr* scr = Map.Scr(pos, CurrentLayer);
9120 if (!scr || !scr->is_valid())
9121 continue;
9122
9123 if (draw_mode == dm_auto)
9124 draw_autocombo(pos, gui_mouse_b() & 2);
9125 else
9126 Map.DoSetComboCommand(pos, include_combos ? Combo : -1, CSet);
9127 }
9128 }
9129 Map.FinishListCommand();
9130
9131 refresh(rMAP+rSCRMAP);
9132 }
9133 void flood_flag()
9134 {
9135 ComboPosition pos = get_mapscreen_mouse_combo_pos();
9136 mapscr* scr = Map.ScrMakeValid(pos, CurrentLayer);
9137 if (!scr || !scr->is_valid())
9138 return;
9139
9140 saved=false;
9141
9142 int num_combos_width = 16 * Map.getViewSize();
9143 int num_combos_height = 11 * Map.getViewSize();
9144
9145 Map.StartListCommand();
9146 for (int x = 0; x < num_combos_width; x++)
9147 {
9148 for (int y = 0; y < num_combos_height; y++)
9149 {
9150 ComboPosition pos = {x, y};
9151 mapscr* scr = Map.Scr(pos, CurrentLayer);
9152 if (!scr || !scr->is_valid())
9153 continue;
9154
9155 Map.DoSetFlagCommand(pos, Flag);
9156 }
9157 }
9158 Map.FinishListCommand();
9159
9160 refresh(rMAP+rSCRMAP);
9161 }
9162
9163 void fill_4()
9164 {
9165 ComboPosition pos = get_mapscreen_mouse_combo_pos();
9166 mapscr* scr = Map.ScrMakeValid(pos, CurrentLayer);
9167 if (!scr)
9168 return;
9169
9170 int c = pos.truncate();
9171 if (draw_mode == dm_cpool || draw_mode == dm_auto
9172 || (scr->cset[c]!=CSet || (scr->data[c]!=Combo && !(key[KEY_LSHIFT]||key[KEY_RSHIFT]))))
9173 {
9174 saved=false;
9175
9176 Map.StartListCommand();
9177 if (draw_mode == dm_auto && (combo_autos[combo_auto_pos].getType() == AUTOCOMBO_FENCE ||
9178 combo_autos[combo_auto_pos].getType() == AUTOCOMBO_Z4))
9179 {
9180 draw_autocombo_command(pos);
9181 }
9182 else
9183 {
9184 bool allow_diagonal = false;
9185 fill(scr->data[c], scr->cset[c], pos, allow_diagonal, (key[KEY_LSHIFT] || key[KEY_RSHIFT]));
9186 }
9187 Map.FinishListCommand();
9188 refresh(rMAP+rSCRMAP);
9189 }
9190 }
9191 void fill_4_flag()
9192 {
9193 ComboPosition pos = get_mapscreen_mouse_combo_pos();
9194 mapscr* scr = Map.ScrMakeValid(pos, CurrentLayer);
9195 if (!scr)
9196 return;
9197
9198 int flag = scr->sflag[pos.truncate()];
9199 if (flag != Flag)
9200 {
9201 saved=false;
9202
9203 Map.StartListCommand();
9204 bool allow_diagonal = false;
9205 fill_flag(flag, pos, allow_diagonal);
9206 Map.FinishListCommand();
9207 refresh(rMAP+rSCRMAP);
9208 }
9209 }
9210 void fill_8()
9211 {
9212 ComboPosition pos = get_mapscreen_mouse_combo_pos();
9213 mapscr* scr = Map.ScrMakeValid(pos, CurrentLayer);
9214 if (!scr)
9215 return;
9216
9217 int c = pos.truncate();
9218 if (draw_mode == dm_cpool || draw_mode == dm_auto
9219 || (scr->cset[c] != CSet ||
9220 (scr->data[c] != Combo &&
9221 !(key[KEY_LSHIFT]||key[KEY_RSHIFT]))))
9222 {
9223 saved=false;
9224
9225 Map.StartListCommand();
9226 bool allow_diagonal = true;
9227 fill(scr->data[c], scr->cset[c], pos, allow_diagonal, (key[KEY_LSHIFT]||key[KEY_RSHIFT]));
9228 Map.FinishListCommand();
9229
9230 refresh(rMAP+rSCRMAP);
9231 }
9232 }
9233 void fill_8_flag()
9234 {
9235 ComboPosition pos = get_mapscreen_mouse_combo_pos();
9236 mapscr* scr = Map.ScrMakeValid(pos, CurrentLayer);
9237 if (!scr)
9238 return;
9239
9240 int flag = scr->sflag[pos.truncate()];
9241 if (flag != Flag)
9242 {
9243 saved=false;
9244
9245 Map.StartListCommand();
9246 bool allow_diagonal = true;
9247 fill_flag(flag, pos, allow_diagonal);
9248 Map.FinishListCommand();
9249 refresh(rMAP+rSCRMAP);
9250 }
9251 }
9252
9253 void fill2_4()
9254 {
9255 ComboPosition pos = get_mapscreen_mouse_combo_pos();
9256 mapscr* scr = Map.ScrMakeValid(pos, CurrentLayer);
9257 if (!scr)
9258 return;
9259
9260 saved=false;
9261
9262 Map.StartListCommand();
9263 fill2(Combo, CSet, pos, 255, 0, (key[KEY_LSHIFT]||key[KEY_RSHIFT]));
9264 Map.FinishListCommand();
9265 refresh(rMAP+rSCRMAP);
9266 }
9267
9268 void fill2_8()
9269 {
9270 ComboPosition pos = get_mapscreen_mouse_combo_pos();
9271 mapscr* scr = Map.ScrMakeValid(pos, CurrentLayer);
9272 if (!scr)
9273 return;
9274
9275 saved=false;
9276
9277 Map.StartListCommand();
9278 fill2(Combo, CSet, pos, 255, 1, (key[KEY_LSHIFT]||key[KEY_RSHIFT]));
9279 Map.FinishListCommand();
9280
9281 refresh(rMAP+rSCRMAP);
9282 }
9283
9284
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu fill_menu
9285 72 {
9286
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Flood", set_flood, 0 },
9287
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Fill (4-way)", set_fill_4, 1 },
9288
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Fill (8-way)", set_fill_8, 2 },
9289
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Fill2 (4-way)", set_fill2_4, 3 },
9290
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Fill2 (8-way)", set_fill2_8, 4 },
9291 };
9292 void set_filltype(int ty)
9293 {
9294 fill_type = ty;
9295 fill_menu.select_only_uid(ty);
9296 }
9297
9298 int32_t set_flood()
9299 {
9300 set_filltype(0);
9301 return D_O_K;
9302 }
9303
9304 int32_t set_fill_4()
9305 {
9306 set_filltype(1);
9307 return D_O_K;
9308 }
9309
9310 int32_t set_fill_8()
9311 {
9312 set_filltype(2);
9313 return D_O_K;
9314 }
9315
9316 int32_t set_fill2_4()
9317 {
9318 set_filltype(3);
9319 return D_O_K;
9320 }
9321
9322 int32_t set_fill2_8()
9323 {
9324 set_filltype(4);
9325 return D_O_K;
9326 }
9327
9328 int32_t draw_block_1_2()
9329 {
9330 draw_block(mouse_combo_pos,1,2);
9331 return D_O_K;
9332 }
9333
9334 int32_t draw_block_2_1()
9335 {
9336 draw_block(mouse_combo_pos,2,1);
9337 return D_O_K;
9338 }
9339
9340 int32_t draw_block_2_2()
9341 {
9342 draw_block(mouse_combo_pos,2,2);
9343 return D_O_K;
9344 }
9345
9346 int32_t draw_block_2_3()
9347 {
9348 draw_block(mouse_combo_pos,2,3);
9349 return D_O_K;
9350 }
9351
9352 int32_t draw_block_3_2()
9353 {
9354 draw_block(mouse_combo_pos,3,2);
9355 return D_O_K;
9356 }
9357
9358 int32_t draw_block_3_3()
9359 {
9360 draw_block(mouse_combo_pos,3,3);
9361 return D_O_K;
9362 }
9363
9364 int32_t draw_block_4_2()
9365 {
9366 draw_block(mouse_combo_pos,4,2);
9367 return D_O_K;
9368 }
9369
9370 int32_t draw_block_4_4()
9371 {
9372 draw_block(mouse_combo_pos,4,4);
9373 return D_O_K;
9374 }
9375
9376
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu draw_block_menu
9377 108 {
9378
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "1x2", draw_block_1_2 },
9379
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "2x1", draw_block_2_1 },
9380
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "2x2", draw_block_2_2 },
9381
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "2x3", draw_block_2_3 },
9382
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "3x2", draw_block_3_2 },
9383
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "3x3", draw_block_3_3 },
9384
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "4x2", draw_block_4_2 },
9385
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "4x4", draw_block_4_4 },
9386 };
9387
9388
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu paste_screen_menu
9389 60 {
9390
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Paste", onPaste },
9391
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Paste All", onPasteAll },
9392
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Paste to All", onPasteToAll },
9393
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Paste All to All", onPasteAllToAll },
9394 };
9395
9396 int32_t scrollto_cmb(int32_t cid)
9397 {
9398 auto& sqr = combolist[current_combolist];
9399 int32_t res = vbound(cid-(sqr.w*sqr.h/2),0,MAXCOMBOS-(sqr.w*sqr.h));
9400 res -= res%sqr.w;
9401 return res;
9402 }
9403 int32_t scrollto_alias(int32_t alid)
9404 {
9405 auto& sqr = comboaliaslist[current_comboalist];
9406 int32_t res = vbound(alid-(sqr.w*sqr.h/2),0,MAXCOMBOALIASES-(sqr.w*sqr.h));
9407 res -= res%sqr.w;
9408 return res;
9409 }
9410
9411 int32_t scrollto_cpool(int32_t cpid)
9412 {
9413 auto& sqr = comboaliaslist[current_cpoollist];
9414 int32_t res = vbound(cpid-(sqr.w*sqr.h/2),0,MAXCOMBOPOOLS-(sqr.w*sqr.h));
9415 res -= res%sqr.w;
9416 return res;
9417 }
9418
9419 int32_t scrollto_cauto(int32_t caid)
9420 {
9421 auto& sqr = comboaliaslist[current_cautolist];
9422 int32_t res = vbound(caid - (sqr.w * sqr.h / 2), 0, MAXCOMBOPOOLS - (sqr.w * sqr.h));
9423 res -= res % sqr.w;
9424 return res;
9425 }
9426
9427 void add_favorite_combo_block(int32_t favind, int32_t cid, bool force)
9428 {
9429 int32_t w = vbound(BrushWidth, 1, 4);
9430 int32_t h = vbound(BrushHeight, 1, 7);
9431 for (int32_t xi = 0; xi < w; ++xi)
9432 {
9433 for (int32_t yi = 0; yi < h; ++yi)
9434 {
9435 int32_t cx = cid % 4;
9436 int32_t cy = cid / 4;
9437 int32_t cc = (cy + yi) * 4 + cx + xi;
9438 int32_t fx = favind % FAVORITECOMBO_PER_ROW;
9439 int32_t fy = favind / FAVORITECOMBO_PER_ROW;
9440 int32_t fc = (fy + yi) * FAVORITECOMBO_PER_ROW + fx + xi + FAVORITECOMBO_PER_PAGE * FavoriteComboPage;
9441
9442 if (cx + xi < 4 && cc < MAXCOMBOS && fx + xi < FAVORITECOMBO_PER_ROW && fy + yi < FAVORITECOMBO_PER_COLUMN)
9443 {
9444 if (favorite_combos[fc] < 0 || force)
9445 {
9446 favorite_combo_modes[fc] = dm_normal;
9447 favorite_combos[fc] = cc;
9448 }
9449 }
9450 }
9451 }
9452 }
9453
9454 void onRCSelectCombo(int32_t c)
9455 {
9456 int32_t drawmap, drawscr;
9457
9458 if(CurrentLayer==0)
9459 {
9460 drawmap=Map.getCurrMap();
9461 drawscr=Map.getCurrScr();
9462 }
9463 else
9464 {
9465 drawmap=Map.CurrScr()->layermap[CurrentLayer-1]-1;
9466 drawscr=Map.CurrScr()->layerscreen[CurrentLayer-1];
9467 }
9468 mapscr* draw_mapscr = Map.AbsoluteScr(drawmap, drawscr);
9469 if(!draw_mapscr) return;
9470
9471 Combo=draw_mapscr->data[c];
9472 if(AutoBrush)
9473 BrushWidth = BrushHeight = 1;
9474 }
9475
9476 void onRCScrollToombo(int32_t c)
9477 {
9478 int32_t drawmap, drawscr;
9479
9480 if(CurrentLayer==0)
9481 {
9482 drawmap=Map.getCurrMap();
9483 drawscr=Map.getCurrScr();
9484 }
9485 else
9486 {
9487 drawmap=Map.CurrScr()->layermap[CurrentLayer-1]-1;
9488 drawscr=Map.CurrScr()->layerscreen[CurrentLayer-1];
9489 }
9490 mapscr* draw_mapscr = Map.AbsoluteScr(drawmap, drawscr);
9491 if(!draw_mapscr) return;
9492
9493 auto& sqr = combolist[current_combolist];
9494 First[current_combolist]=scrollto_cmb(draw_mapscr->data[c]);
9495 }
9496
9497 enum
9498 {
9499 MENUID_RCSCREEN_PASTE,
9500 MENUID_RCSCREEN_ADVPASTE,
9501 MENUID_RCSCREEN_SPECPASTE,
9502 };
9503
1/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 static NewMenu rc_menu_screen
9504 60 {
9505
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Copy Screen", onCopy },
9506
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "Paste Screen", &paste_screen_menu, MENUID_RCSCREEN_PASTE },
9507
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "...Advanced Paste", &paste_menu, MENUID_RCSCREEN_ADVPASTE },
9508
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 { "...Special Paste", &paste_item_menu, MENUID_RCSCREEN_SPECPASTE },
9509 };
9510
9511 void call_options_dlg();
9512 int32_t onOptions()
9513 {
9514 call_options_dlg();
9515 brush_menu.select_uid(MENUID_BRUSH_AUTOBRUSH, AutoBrush);
9516 brush_menu.disable_uid(MENUID_BRUSH_WIDTH, AutoBrush);
9517 brush_menu.disable_uid(MENUID_BRUSH_HEIGHT, AutoBrush);
9518 brush_menu.select_uid(MENUID_BRUSH_FLOATBRUSH, FloatBrush);
9519 brush_menu.select_uid(MENUID_BRUSH_COMBOBRUSH, ComboBrush);
9520 return D_O_K;
9521 }
9522
9523 void follow_twarp(int warpindex)
9524 {
9525 if(warpindex >= 4)
9526 {
9527 InfoDialog("Random Tile Warp",
9528 "This is a random tile warp combo, so it chooses"
9529 " randomly between the screen's four Tile Warps.").show();
9530 warpindex=zc_oldrand()&3;
9531 }
9532
9533 int32_t tm = Map.getCurrMap();
9534 int32_t ts = Map.getCurrScr();
9535 int32_t wt = Map.CurrScr()->tilewarptype[warpindex];
9536
9537 if(wt==wtCAVE || wt==wtNOWARP)
9538 {
9539 char buf[56];
9540 InfoDialog(warptype_string[wt],fmt::format("This screen's Tile Warp {} is set to {}, so it doesn't lead to another screen.",'A'+warpindex,warptype_string[wt]));
9541 return;
9542 }
9543
9544 Map.dowarp(0,warpindex);
9545
9546 if(ts!=Map.getCurrScr() || tm!=Map.getCurrMap())
9547 {
9548 FlashWarpSquare = (TheMaps[tm*MAPSCRS+ts].warpreturnc>>(warpindex*2))&3;
9549 FlashWarpClk = 32;
9550 }
9551 }
9552 void edit_twarp(int warpindex)
9553 {
9554 if(warpindex>=4)
9555 {
9556 InfoDialog("Random Tile Warp",
9557 "This is a random tile warp combo, so it chooses"
9558 " randomly between the screen's four Tile Warps.").show();
9559 warpindex=zc_oldrand()&3;
9560 }
9561
9562 if(warpindex > -1 && warpindex < 4)
9563 onTileWarpIndex(warpindex);
9564 }
9565
9566 int toggle_linked_scrolling()
9567 {
9568 LinkedScroll = LinkedScroll ? 0 : 1;
9569 zc_set_config("zquest","linked_comboscroll",LinkedScroll);
9570 return D_O_K;
9571 }
9572 void on_scroll_cpane()
9573 {
9574 switch (draw_mode)
9575 {
9576 case dm_alias:
9577 combo_alistpos[current_comboalist] = scrollto_alias(combo_apos);
9578 break;
9579 case dm_cpool:
9580 combo_pool_listpos[current_cpoollist] = scrollto_cpool(combo_pool_pos);
9581 break;
9582 case dm_auto:
9583 combo_auto_listpos[current_cautolist] = scrollto_cauto(combo_auto_pos);
9584 break;
9585 default:
9586 First[current_combolist] = scrollto_cmb(Combo);
9587 break;
9588 }
9589 }
9590 void on_edit_cpane()
9591 {
9592 switch (draw_mode)
9593 {
9594 case dm_alias:
9595 onEditComboAlias();
9596 break;
9597 case dm_cpool:
9598 onEditComboPool();
9599 break;
9600 case dm_auto:
9601 onEditAutoCombo();
9602 break;
9603 default:
9604 reset_combo_animations();
9605 reset_combo_animations2();
9606 edit_combo(Combo, true, CSet);
9607 setup_combo_animations();
9608 setup_combo_animations2();
9609 break;
9610 }
9611 }
9612 void on_cpane_page()
9613 {
9614 switch(draw_mode)
9615 {
9616 case dm_normal:
9617 combo_screen(Combo>>8,Combo);
9618 break;
9619 case dm_alias:
9620 call_alias_pages(combo_apos);
9621 break;
9622 case dm_auto:
9623 call_autoc_pages(combo_auto_pos);
9624 break;
9625 case dm_cpool:
9626 call_cpool_pages(combo_pool_pos);
9627 break;
9628 }
9629 }
9630 void open_cpane_tilepage()
9631 {
9632 onGotoTiles(combobuf[Combo].o_tile);
9633 }
9634 static int _clicked_fav = 0;
9635 void fav_rc_remove()
9636 {
9637 favorite_combo_modes[_clicked_fav] = dm_normal;
9638 favorite_combos[_clicked_fav] = -1;
9639 saved = false;
9640 }
9641 void popup_favorites_rc(int f, int x, int y)
9642 {
9643 _clicked_fav = f;
9644 string type;
9645 switch (draw_mode)
9646 {
9647 case dm_alias:
9648 type = "Alias";
9649 break;
9650 case dm_cpool:
9651 type = "Pool";
9652 break;
9653 case dm_auto:
9654 type = "Autocombo";
9655 break;
9656 case dm_normal:
9657 type = "Combo";
9658 break;
9659 default: return;
9660 }
9661 NewMenu rcmenu
9662 {
9663 { fmt::format("Scroll to {}", type), on_scroll_cpane },
9664 { fmt::format("Edit {}", type), on_edit_cpane },
9665 { fmt::format("Open {} Page", type), on_cpane_page },
9666 { fmt::format("Remove Fav {}", type), fav_rc_remove },
9667 };
9668 switch (draw_mode)
9669 {
9670 case dm_normal:
9671 rcmenu.add({
9672 {},
9673 { "Open Tile Page", open_cpane_tilepage },
9674 });
9675 break;
9676 }
9677 rcmenu.pop(x, y);
9678 }
9679 void popup_cpane_rc(int x, int y)
9680 {
9681 string type;
9682 switch (draw_mode)
9683 {
9684 case dm_alias:
9685 type = "Alias";
9686 break;
9687 case dm_cpool:
9688 type = "Pool";
9689 break;
9690 case dm_auto:
9691 type = "Autocombo";
9692 break;
9693 case dm_normal:
9694 type = "Combo";
9695 break;
9696 default: return;
9697 }
9698 NewMenu rcmenu;
9699 switch(draw_mode)
9700 {
9701 case dm_normal:
9702 rcmenu.add({
9703 { fmt::format("Edit {}", type), on_edit_cpane },
9704 { fmt::format("Open {} Page", type), on_cpane_page },
9705 { "Open Tile Page", open_cpane_tilepage },
9706 { "Combo Locations", onComboLocationReport },
9707 {},
9708 { "Scroll to Page...", onGotoPage },
9709 { "Linked Scrolling", toggle_linked_scrolling, nullopt, LinkedScroll ? MFL_SEL : 0 },
9710 });
9711 break;
9712 case dm_alias:
9713 case dm_cpool:
9714 case dm_auto:
9715 rcmenu.add({
9716 { fmt::format("Edit {}", type), on_edit_cpane },
9717 { fmt::format("Open {} Page", type), on_cpane_page },
9718 {},
9719 { "Scroll to Page...", onGotoPage },
9720 { "Linked Scrolling", toggle_linked_scrolling, nullopt, LinkedScroll ? MFL_SEL : 0 },
9721 });
9722 break;
9723 }
9724 rcmenu.pop(x, y);
9725 }
9726
9727 void set_brush_width(int32_t width)
9728 {
9729 BrushWidth = width;
9730 for(int q = 0; q < brush_width_menu.size(); ++q)
9731 brush_width_menu.at(q)->select(q==BrushWidth-1);
9732 refresh(rALL);
9733 }
9734
9735 void set_brush_height(int32_t height)
9736 {
9737 BrushHeight = height;
9738 for(int q = 0; q < brush_height_menu.size(); ++q)
9739 brush_height_menu.at(q)->select(q==BrushHeight-1);
9740 refresh(rALL);
9741 }
9742
9743 1 void restore_mouse()
9744 {
9745 1 ComboBrushPause=1;
9746 1 MouseSprite::set(ZQM_NORMAL);
9747 1 }
9748
9749 static int32_t comboa_cnt=0;
9750 static int32_t combop_cnt=0;
9751 static int32_t layer_cnt=0;
9752
9753 static char paste_ffc_menu_text[21];
9754 static char paste_ffc_menu_text2[21];
9755 static char follow_warp_menu_text[21];
9756 static char follow_warp_menu_text2[21];
9757
9758 static int fake_mouse_b(){return 0;}
9759 static int (*mouseb_proc)();
9760 static bool killed_mouse = false;
9761 void zq_killmouse()
9762 {
9763 if(killed_mouse) return;
9764 mouseb_proc = gui_mouse_b;
9765 gui_mouse_b = fake_mouse_b;
9766 killed_mouse = true;
9767 }
9768 void zq_restoremouse()
9769 {
9770 if(!killed_mouse) return;
9771 gui_mouse_b = mouseb_proc;
9772 killed_mouse = false;
9773 }
9774
9775
9776 void domouse()
9777 {
9778 static int mouse_down = 0;
9779 static int32_t scrolldelay = 0;
9780 auto mousexy = zc_get_mouse();
9781 auto x = mousexy.first;
9782 auto y = mousexy.second;
9783 double startx=mapscreen_x+(showedges?(16*mapscreen_single_scale):0);
9784 double starty=mapscreen_y+(showedges?(16*mapscreen_single_scale):0);
9785 int32_t startxint=mapscreen_x+(showedges?int32_t(16*mapscreen_single_scale):0);
9786 int32_t startyint=mapscreen_y+(showedges?int32_t(16*mapscreen_single_scale):0);
9787 int32_t cx=(x-startx)/(16*mapscreen_single_scale);
9788 int32_t cy=(y-starty)/(16*mapscreen_single_scale);
9789 ComboPosition combo_pos = {cx, cy};
9790
9791 if (draw_mode == dm_auto)
9792 {
9793 if (combo_pos != mouse_combo_pos)
9794 combobrushoverride = get_autocombo_floating_cid(combo_pos, false);
9795 }
9796 else
9797 combobrushoverride = -1;
9798
9799 mouse_combo_pos = combo_pos;
9800 update_combobrush();
9801
9802 ++scrolldelay;
9803
9804 bool x_on_list = false;
9805 for(auto q = 0; q < num_combo_cols; ++q)
9806 {
9807 if((x>=combolist[q].x) && (x<combolist[q].x+(combolist[q].xscale*combolist[q].w)))
9808 {
9809 x_on_list = true;
9810 break;
9811 }
9812 }
9813 if(MouseScroll && x_on_list && (key[KEY_LSHIFT] || key[KEY_RSHIFT] || (scrolldelay&3)==0))
9814 {
9815 int32_t test_list=0;
9816
9817 for(test_list=0; test_list<num_combo_cols; ++test_list)
9818 {
9819 if((x>=combolist[test_list].x) && (x<combolist[test_list].x+(combolist[test_list].xscale*combolist[test_list].w)))
9820 {
9821 break;
9822 }
9823 }
9824
9825 if(test_list<num_combo_cols)
9826 {
9827 if(y>=combolist[test_list].y-mouse_scroll_h && y<=combolist[test_list].y && First[test_list])
9828 {
9829 if((CHECK_CTRL_CMD)&&(key[KEY_ALT] || key[KEY_ALTGR]))
9830 {
9831 First[test_list]=0;
9832 }
9833 else if(CHECK_CTRL_CMD)
9834 {
9835 First[test_list]-=zc_min(First[test_list],256);
9836 }
9837 else if(key[KEY_ALT] || key[KEY_ALTGR])
9838 {
9839 First[test_list]-=zc_min(First[test_list],(combolist[test_list].w*combolist[test_list].h));
9840 }
9841 else
9842 {
9843 First[test_list]-=zc_min(First[test_list],combolist[test_list].w);
9844 }
9845 }
9846
9847 if(y>=combolist[test_list].y+(combolist[test_list].h*combolist[test_list].yscale)-1 && y<combolist[test_list].y+(combolist[test_list].h*combolist[test_list].yscale)+mouse_scroll_h-1 && First[test_list]<(MAXCOMBOS-(combolist[test_list].w*combolist[test_list].h)))
9848 {
9849 int32_t offset = combolist[test_list].w*combolist[test_list].h;
9850
9851 if((CHECK_CTRL_CMD)&&(key[KEY_ALT] || key[KEY_ALTGR]))
9852 {
9853 First[test_list]=MAXCOMBOS-offset;
9854 }
9855 else if(CHECK_CTRL_CMD)
9856 {
9857 First[test_list] = zc_min(MAXCOMBOS-offset, First[test_list]+256);
9858 }
9859 else if(key[KEY_ALT] || key[KEY_ALTGR])
9860 {
9861 First[test_list] = zc_min(MAXCOMBOS-offset, First[test_list]+ offset);
9862 }
9863 else
9864 {
9865 First[test_list] = zc_min(MAXCOMBOS - offset, First[test_list] + combolist[test_list].w);
9866 }
9867 }
9868 }
9869 }
9870
9871 // The screen for this combo_pos, layer 0. Used to access ffcs.
9872 mapscr* scr = Map.Scr(combo_pos);
9873 // The screen for this combo_pos at the CurrentLayer. Could be same as scr.
9874 mapscr* draw_mapscr = scr && CurrentLayer ? Map.Scr(combo_pos, CurrentLayer) : scr;
9875 int c = combo_pos.truncate();
9876 set_active_visible_screen(scr);
9877
9878 //-------------
9879 //tooltip stuff
9880 //-------------
9881 if (active_visible_screen && isinRect(x,y,startxint,startyint,startxint+(256*mapscreen_screenunit_scale)-1,startyint+(176*mapscreen_screenunit_scale)-1))
9882 {
9883 static int mapscr_tooltip_id = ttip_register_id();
9884 bool did_ffttip = false;
9885 int num_ffcs = scr->numFFC();
9886 for(int32_t i=num_ffcs-1; i>=0; i--)
9887 if(scr->ffcs[i].data !=0 && (scr->ffcs[i].layer >= CurrentLayer || (scr->ffcs[i].flags&ffc_overlay)))
9888 {
9889 int32_t ffx = scr->ffcs[i].x.getFloor() + active_visible_screen->dx * 256;
9890 int32_t ffy = scr->ffcs[i].y.getFloor() + active_visible_screen->dy * 176;
9891 int32_t ffw = scr->ffTileWidth(i)*16;
9892 int32_t ffh = scr->ffTileHeight(i)*16;
9893 int32_t cx2 = (x-startxint)/mapscreen_single_scale;
9894 int32_t cy2 = (y-startyint)/mapscreen_single_scale;
9895
9896 if(cx2 >= ffx && cx2 < ffx+ffw && cy2 >= ffy && cy2 < ffy+ffh)
9897 {
9898 // FFC tooltip
9899 if(tooltip_current_ffc != i)
9900 {
9901 clear_tooltip();
9902 }
9903
9904 tooltip_current_ffc = i;
9905 char msg[1024] = {0};
9906 auto& ff = scr->ffcs[i];
9907 sprintf(msg,"FFC: %d Combo: %d\nCSet: %d Type: %s\nScript: %s",
9908 i+1, ff.data,ff.data,
9909 combo_class_buf[combobuf[ff.data].type].name,
9910 (ff.script<=0 ? "(None)" : ffcmap[ff.script-1].scriptname.substr(0,400).c_str()));
9911 ttip_install(mapscr_tooltip_id, msg, startxint+(ffx*mapscreen_single_scale), startyint+(ffy*mapscreen_single_scale), ffw*mapscreen_single_scale, ffh*mapscreen_single_scale, x, y);
9912 did_ffttip = true;
9913 break;
9914 }
9915 }
9916 if(!did_ffttip)
9917 {
9918 if(unsigned(c) < 176 && draw_mapscr && !gui_mouse_b())
9919 {
9920 int cid = draw_mapscr->data[c];
9921 newcombo const& cmb = combobuf[cid];
9922 std::ostringstream oss;
9923 int cs = draw_mapscr->cset[c];
9924 int sflag = draw_mapscr->sflag[c];
9925 oss << "Pos: " << c
9926 << "\nCombo: " << cid
9927 << "\nCSet: " << cs;
9928 if(sflag || cmb.flag)
9929 oss << "\nFlags: " << sflag << ", " << (int)cmb.flag;
9930 if(cmb.type)
9931 oss << "\nCombo type: " << combo_class_buf[cmb.type].name;
9932 if(cmb.label[0])
9933 oss << "\nLabel: " << cmb.label;
9934 ttip_install(mapscr_tooltip_id, oss.str().c_str(), startxint+(cx*16*mapscreen_single_scale), startyint+(cy*16*mapscreen_single_scale), 16*mapscreen_single_scale, 16*mapscreen_single_scale, x, y);
9935 }
9936 }
9937 }
9938
9939 {
9940 size_and_pos* squares[4] = {&itemsqr_pos,&stairsqr_pos,&warparrival_pos,&flagsqr_pos};
9941 for(int32_t j=0; j<4; j++)
9942 {
9943 auto& square = *squares[j];
9944 if(square.rect(x,y))
9945 {
9946 char msg[160];
9947 sprintf(msg,
9948 j==0 ? "Item Location" :
9949 j==1 ? "Stairs Secret\nTriggered when a Trigger Push Block is pushed." :
9950 j==2 ? "Arrival Square\nPlayer's location when they begin/resume the game." :
9951 "Combo Flags");
9952 update_tooltip(x,y,square,msg);
9953 }
9954 }
9955
9956 // Warp Returns
9957 for(int32_t j=0; j<4; j++)
9958 {
9959 size_and_pos& wret = warpret_pos[j];
9960 if(wret.rect(x,y))
9961 {
9962 char msg[160];
9963 sprintf(msg,"Warp Return Square %c\nPlayer's destination after warping to this screen.",(char)('A'+j));
9964 update_tooltip(x,y,wret,msg);
9965 }
9966 }
9967
9968 // Enemies
9969 if(enemy_prev_pos.rect(x,y))
9970 {
9971 char msg[160];
9972 sprintf(msg,"Enemies that appear on this screen.");
9973 update_tooltip(x,y,enemy_prev_pos,msg);
9974 }
9975
9976 int32_t cmd = commands_list.rectind(x,y);
9977 if(cmd > -1)
9978 {
9979 update_tooltip(x,y,commands_list.subsquare(cmd),
9980 fmt::format("Fav Command {}: {}\n{}", cmd,
9981 get_hotkey_name(favorite_commands[cmd]),
9982 get_hotkey_helptext(favorite_commands[cmd])).c_str());
9983 }
9984 }
9985
9986 if(draw_mode==dm_alias)
9987 {
9988 for(int32_t j=0; j<num_combo_cols; ++j)
9989 {
9990 auto& sqr = comboaliaslist[j];
9991 auto ind = sqr.rectind(x,y);
9992 if(ind > -1)
9993 {
9994 auto c2=ind+combo_alistpos[j];
9995 char msg[80];
9996 sprintf(msg, "Combo alias %d", c2);
9997 update_tooltip(x,y,sqr.subsquare(ind), msg);
9998 }
9999 }
10000 }
10001 else if(draw_mode==dm_cpool)
10002 {
10003 for(int32_t j=0; j<num_combo_cols; ++j)
10004 {
10005 auto& sqr = comboaliaslist[j];
10006 auto ind = sqr.rectind(x,y);
10007 if(ind > -1)
10008 {
10009 auto c2=ind+combo_pool_listpos[j];
10010 char msg[80];
10011 sprintf(msg, "Combo Pool %d", c2);
10012 update_tooltip(x,y,sqr.subsquare(ind), msg);
10013 }
10014 }
10015 if(cpool_prev_visible && combopool_prevbtn.rect(x,y))
10016 {
10017 if(do_layer_button_reset(combopool_prevbtn.x,combopool_prevbtn.y,
10018 combopool_prevbtn.w,combopool_prevbtn.h,
10019 weighted_cpool ? "Weighted" : "Unweighted",0,true))
10020 {
10021 weighted_cpool = !weighted_cpool;
10022 }
10023 }
10024 }
10025 else if (draw_mode == dm_auto)
10026 {
10027 for (int32_t j = 0; j < num_combo_cols; ++j)
10028 {
10029 auto& sqr = comboaliaslist[j];
10030 auto ind = sqr.rectind(x, y);
10031 if (ind > -1)
10032 {
10033 auto c2 = ind + combo_auto_listpos[j];
10034 char msg[80];
10035 sprintf(msg, "Auto Combo %d", c2);
10036 update_tooltip(x, y, sqr.subsquare(ind), msg);
10037 }
10038 }
10039 }
10040 else
10041 {
10042 if(combo_preview.rect(x,y))
10043 {
10044 auto str = "Combo Colors:\n"+get_combo_colornames(Combo,CSet);
10045 update_tooltip(x,y,combo_preview,str.c_str());
10046 }
10047 else if(comboprev_buf[0] && combo_preview_text1.rect(x,y))
10048 {
10049 update_tooltip(x,y,combo_preview_text1,comboprev_buf);
10050 }
10051 else if(comboprev_buf2[0] && combo_preview_text2.rect(x,y))
10052 {
10053 update_tooltip(x,y,combo_preview_text2,comboprev_buf2);
10054 }
10055 else for(int32_t j=0; j<num_combo_cols; ++j)
10056 {
10057 auto& sqr = combolist[j];
10058 auto ind = sqr.rectind(x,y);
10059 if(ind > -1)
10060 {
10061 int32_t c2=ind+First[j];
10062 std::ostringstream oss;
10063 newcombo const& cmb = combobuf[c2];
10064 oss << "Combo " << c2 << ": " << combo_class_buf[cmb.type].name;
10065 if(cmb.flag != 0)
10066 oss << "\nInherent flag: " << ZI.getMapFlagName(cmb.flag);
10067 if(!cmb.label.empty())
10068 oss << "\nLabel: " << cmb.label;
10069
10070 update_tooltip(x,y,sqr.subsquare(ind), oss.str().c_str());
10071 }
10072 }
10073 }
10074
10075 if (favorites_list.rect(x, y))
10076 {
10077 int32_t f = favorites_list.rectind(x, y);
10078 int32_t row = f / favorites_list.w;
10079 int32_t col = f % favorites_list.w;
10080 f = (row * FAVORITECOMBO_PER_ROW) + col;
10081
10082 auto& sqr = favorites_list.subsquare(col, row);
10083
10084 char buf[180];
10085 if (favorite_combos[f] == -1)
10086 sprintf(buf, "Fav Combo %d\nEmpty", f);
10087 else
10088 {
10089 switch (favorite_combo_modes[f])
10090 {
10091 case dm_alias:
10092 sprintf(buf, "Fav Combo %d\nAlias %d", f, favorite_combos[f]);
10093 break;
10094 case dm_cpool:
10095 sprintf(buf, "Fav Combo %d\nPool %d", f, favorite_combos[f]);
10096 break;
10097 case dm_auto:
10098 sprintf(buf, "Fav Combo %d\nAutocombo %d", f, favorite_combos[f]);
10099 break;
10100 default:
10101 sprintf(buf, "Fav Combo %d\nCombo %d", f, favorite_combos[f]);
10102 }
10103 }
10104 update_tooltip(x, y, sqr, buf);
10105 }
10106
10107 size_and_pos const& real_mini = zoomed_minimap ? real_minimap_zoomed : real_minimap;
10108 auto ind = real_mini.rectind(x,y);
10109 if(ind > -1)
10110 {
10111 char buf[80];
10112 sprintf(buf,"0x%02X (%d)", ind, ind);
10113 ttip_install(minimap_tooltip_id, buf, real_mini.subsquare(ind), real_mini.x+real_mini.tw(), real_mini.y-16);
10114 ttip_set_highlight_thickness(minimap_tooltip_id, zoomed_minimap ? 2 : 1);
10115 // Make sure always above the other tooltip items to the right of the map (even in big map mode).
10116 ttip_set_z_index(minimap_tooltip_id, 100);
10117 ttip_clear_timer();
10118 }
10119 else
10120 {
10121 ttip_uninstall(minimap_tooltip_id);
10122 }
10123
10124 // Mouse clicking stuff
10125 int real_mb = gui_mouse_b();
10126 int mb = real_mb & ~mouse_down; //Only handle clicks that have not been handled already
10127 auto mz = mouse_z;
10128 bool lclick = mb&1;
10129 bool rclick = mb&2;
10130
10131 if (mb && hotkeys_is_active())
10132 {
10133 hotkeys_toggle_display(false);
10134 while (gui_mouse_b())
10135 {
10136 custom_vsync();
10137 }
10138 return;
10139 }
10140
10141 FONT* tfont = font;
10142 if(zoomed_minimap)
10143 {
10144 if((lclick||rclick) && !minimap_zoomed.rect(x,y))
10145 {
10146 // 'Clicked off'
10147 mmap_set_zoom(false);
10148 goto domouse_doneclick;
10149 }
10150 }
10151
10152 if(real_mb==0)
10153 {
10154 mouse_down = 0;
10155 canfill=true;
10156 }
10157 else if(lclick || rclick)
10158 {
10159 //on the minimap
10160 if(real_mini.rect(x,y))
10161 {
10162 if(lclick)
10163 select_scr();
10164 else if(rclick && !(mouse_down&2))
10165 {
10166 mmap_set_zoom(!zoomed_minimap);
10167 }
10168 goto domouse_doneclick;
10169 }
10170
10171 if(zoomed_minimap && minimap_zoomed.rect(x,y))
10172 goto domouse_doneclick; //Eat clicks
10173
10174 //on the map tabs
10175 font = get_custom_font(CFONT_GUI);
10176 for(int32_t btn=0; btn<mappage_count; ++btn)
10177 {
10178 char tbuf[15];
10179 sprintf(tbuf, "%d:%02X", map_page[btn].map+1, map_page[btn].screen);
10180 auto& sqr = map_page_bar[btn];
10181 if(sqr.rect(x,y))
10182 {
10183 if(do_layer_button_reset(sqr.x,sqr.y,sqr.w,sqr.h,tbuf,(btn==current_mappage?D_SELECTED:0)))
10184 {
10185 draw_layer_button(screen, sqr.x,sqr.y,sqr.w,sqr.h,tbuf,D_SELECTED);
10186 map_page[current_mappage].map=Map.getCurrMap();
10187 map_page[current_mappage].screen=Map.getCurrScr();
10188 current_mappage=btn;
10189 Map.setCurrMap(map_page[current_mappage].map);
10190 Map.setCurrScr(map_page[current_mappage].screen);
10191 rebuild_trans_table(); //Woo
10192 }
10193 goto domouse_doneclick;
10194 }
10195 }
10196
10197 if(compactbtn.rect(x,y))
10198 {
10199 if(do_text_button(compactbtn.x, compactbtn.y, compactbtn.w, compactbtn.h, is_compact ? "< Expand" : "> Compact"));
10200 toggle_is_compact();
10201 goto domouse_doneclick;
10202 }
10203
10204 if(!zoom_in_btn_disabled && zoominbtn.rect(x,y))
10205 {
10206 if(do_text_button(zoominbtn.x, zoominbtn.y, zoominbtn.w, zoominbtn.h, "+"))
10207 change_mapscr_zoom(-1);
10208 goto domouse_doneclick;
10209 }
10210
10211 if(!zoom_out_btn_disabled && zoomoutbtn.rect(x,y))
10212 {
10213 if(do_text_button(zoomoutbtn.x, zoomoutbtn.y, zoomoutbtn.w, zoomoutbtn.h, "-"))
10214 change_mapscr_zoom(1);
10215 goto domouse_doneclick;
10216 }
10217
10218 font = get_zc_font(font_lfont_l);
10219 if(combo_merge_btn.rect(x,y))
10220 {
10221 bool merged = is_compact ? compact_merged_combopane : large_merged_combopane;
10222 if(do_text_button(combo_merge_btn.x,combo_merge_btn.y,combo_merge_btn.w,combo_merge_btn.h,merged ? "<|>" : ">|<"))
10223 {
10224 toggle_merged_mode();
10225 }
10226 goto domouse_doneclick;
10227 }
10228
10229 if(favorites_zoombtn.rect(x,y))
10230 {
10231 bool zoomed = is_compact ? compact_zoomed_fav : large_zoomed_fav;
10232 if(do_text_button(favorites_zoombtn.x,favorites_zoombtn.y,favorites_zoombtn.w,favorites_zoombtn.h,zoomed ? "-" : "+"))
10233 {
10234 toggle_favzoom_mode();
10235 }
10236 goto domouse_doneclick;
10237 }
10238 else if(favorites_x.rect(x,y))
10239 {
10240 if(do_text_button(favorites_x.x,favorites_x.y,favorites_x.w,favorites_x.h,"X"))
10241 {
10242 AlertDialog("Clear Favorite Combos",
10243 "Are you sure you want to clear all favorite combos?",
10244 [&](bool ret,bool)
10245 {
10246 if(ret)
10247 {
10248 for(auto q = 0; q < MAXFAVORITECOMBOS; ++q)
10249 {
10250 favorite_combos[q] = -1;
10251 favorite_combo_modes[q] = dm_normal;
10252 }
10253 saved = false;
10254 refresh(rFAVORITES);
10255 }
10256 }).show();
10257 }
10258 goto domouse_doneclick;
10259 }
10260 else if(favorites_infobtn.rect(x,y))
10261 {
10262 if(do_text_button(favorites_infobtn.x,favorites_infobtn.y,favorites_infobtn.w,favorites_infobtn.h,"?"))
10263 {
10264 InfoDialog("Favorite Combos",
10265 "On LClick (empty): Sets clicked favorite to the current combo."
10266 "\nOn LClick: Sets current combo to clicked favorite."
10267 "\nShift+LClick: Sets clicked favorite to current combo."
10268 "\nCtrl+LClick: Clears clicked favorite."
10269 "\nAlt+LClick: Scrolls to clicked favorite."
10270 "\nRClick: Opens context menu."
10271 "\n\nClick the Page buttons (<-/->) to cycle between pages (RClick to jump to a page)"
10272 "\nClick the Zoom button (+/-) to toggle zoom level."
10273 "\nClick the X button to clear all favorite combos.").show();
10274 }
10275 goto domouse_doneclick;
10276 }
10277 else if(favorites_pgleft.rect(x,y))
10278 {
10279 if (do_text_button(favorites_pgleft.x, favorites_pgleft.y, favorites_pgleft.w, favorites_pgleft.h, is_compact ? "<" : "<-"))
10280 {
10281 if (rclick)
10282 {
10283 if(auto val = popup_num_menu(x, y, 1, 9, FavoriteComboPage, [](int p){return fmt::format("Page {}",p);}))
10284 FavoriteComboPage = vbound(*val-1, 0, 8);
10285 }
10286 else
10287 FavoriteComboPage = FavoriteComboPage == 0 ? 8 : --FavoriteComboPage;
10288 reload_zq_gui();
10289 }
10290 goto domouse_doneclick;
10291 }
10292 else if(favorites_pgright.rect(x,y))
10293 {
10294 if (do_text_button(favorites_pgright.x, favorites_pgright.y, favorites_pgright.w, favorites_pgright.h, is_compact ? ">" : "->"))
10295 {
10296 if (rclick)
10297 {
10298 if(auto val = popup_num_menu(x, y, 1, 9, FavoriteComboPage, [](int p){return fmt::format("Page {}",p);}))
10299 FavoriteComboPage = vbound(*val-1, 0, 8);
10300 }
10301 else
10302 FavoriteComboPage = FavoriteComboPage == 8 ? 0 : ++FavoriteComboPage;
10303 reload_zq_gui();
10304 }
10305 goto domouse_doneclick;
10306 }
10307
10308 if(commands_zoombtn.rect(x,y))
10309 {
10310 bool zoomed = is_compact ? compact_zoomed_cmd : large_zoomed_cmd;
10311 if(do_text_button(commands_zoombtn.x,commands_zoombtn.y,commands_zoombtn.w,commands_zoombtn.h,zoomed ? "-" : "+"))
10312 {
10313 toggle_cmdzoom_mode();
10314 }
10315 goto domouse_doneclick;
10316 }
10317 else if(commands_x.rect(x,y))
10318 {
10319 if(do_text_button(commands_x.x,commands_x.y,commands_x.w,commands_x.h,"X"))
10320 {
10321 AlertDialog("Clear Favorite Commands",
10322 "Are you sure you want to clear all favorite commands?",
10323 [&](bool ret,bool)
10324 {
10325 if(ret)
10326 {
10327 char buf[20];
10328 for(auto q = 0; q < MAXFAVORITECOMMANDS; ++q)
10329 {
10330 write_fav_command(q,0);
10331 }
10332 refresh(rFAVORITES);
10333 }
10334 }).show();
10335 }
10336 goto domouse_doneclick;
10337 }
10338 else if(commands_infobtn.rect(x,y))
10339 {
10340 if(do_text_button(commands_infobtn.x,commands_infobtn.y,commands_infobtn.w,commands_infobtn.h,"?"))
10341 {
10342 InfoDialog("Favorite Commands",
10343 "On LClick (empty): Choose a favorite command"
10344 "\nOn LClick: Runs the favorite command"
10345 "\nShift+Click: Choose a favorite command"
10346 "\nRClick: Choose a favorite command"
10347 "\nCtrl+Click: Clears clicked command"
10348 "\nAlt+Click: Shows info on the favorite command"
10349 "\n\nClick the Zoom button (+/-) to toggle zoom level"
10350 "\nClick the X button to clear all favorite commands").show();
10351 }
10352 goto domouse_doneclick;
10353 }
10354 font=tfont;
10355
10356 // On the layer panel
10357 font = get_custom_font(CFONT_GUI);
10358 for(int32_t i=0; i<=6; ++i)
10359 {
10360 int32_t spacing_offs = is_compact ? 2 : 10;
10361 int32_t rx = (i * (layerpanel_buttonwidth+spacing_offs+layerpanel_checkbox_wid)) + layer_panel.x+(is_compact?2:6);
10362 int32_t ry = layer_panel.y;
10363
10364 if ((i == 0 || mapscreen_valid_layers[i - 1]) && isinRect(x,y,rx,ry,rx+layerpanel_buttonwidth-1,ry+layerpanel_buttonheight-1))
10365 {
10366 char tbuf[15];
10367
10368 if (Map.getViewSize() > 1)
10369 {
10370 sprintf(tbuf, "%d", i);
10371 }
10372 else if (i != 0 && mapscreen_valid_layers[i - 1])
10373 {
10374 if (is_compact)
10375 {
10376 sprintf(tbuf, "%s%d %d:%02X",
10377 (i==2 && Map.CurrScr()->flags7&fLAYER2BG) || (i==3 && Map.CurrScr()->flags7&fLAYER3BG) ? "-":"",
10378 i, Map.CurrScr()->layermap[i-1], Map.CurrScr()->layerscreen[i-1]);
10379 }
10380 else
10381 {
10382 sprintf(tbuf, "%s%d (%d:%02X)",
10383 (i==2 && Map.CurrScr()->flags7&fLAYER2BG) || (i==3 && Map.CurrScr()->flags7&fLAYER3BG) ? "-":"",
10384 i, Map.CurrScr()->layermap[i-1], Map.CurrScr()->layerscreen[i-1]);
10385 }
10386 }
10387 else
10388 {
10389 sprintf(tbuf, "%d", i);
10390 }
10391
10392 if(do_text_button(rx, ry, layerpanel_buttonwidth, layerpanel_buttonheight, tbuf))
10393 {
10394 CurrentLayer = i;
10395 goto domouse_doneclick;
10396 }
10397 }
10398
10399 auto cbyofs = (layerpanel_buttonheight-layerpanel_checkbox_hei)/2;
10400 if(isinRect(x,y,rx+layerpanel_buttonwidth+1,ry+cbyofs,rx+layerpanel_buttonwidth+1+layerpanel_checkbox_wid-1,ry+2+layerpanel_checkbox_hei-1))
10401 {
10402 do_checkbox(menu1,rx+layerpanel_buttonwidth+1,ry+cbyofs,layerpanel_checkbox_wid,layerpanel_checkbox_hei,LayerMaskInt[i]);
10403 goto domouse_doneclick;
10404 }
10405 }
10406 font=tfont;
10407
10408 //Uses lclick/rclick separately
10409
10410 //on the map screen
10411 if(isinRect(x,y,startxint,startyint,startxint+(256*mapscreen_screenunit_scale)-1,startyint+(176*mapscreen_screenunit_scale)-1))
10412 {
10413 if (lclick)
10414 {
10415 Map.setCurrScr(Map.getScreenForPosition(combo_pos));
10416 }
10417
10418 if (draw_mode == dm_auto)
10419 {
10420 if (CHECK_CTRL_CMD)
10421 {
10422 if (canfill)
10423 {
10424 switch (fill_type)
10425 {
10426 case 0:
10427 flood();
10428 break;
10429
10430 case 1:
10431 fill_4();
10432 break;
10433
10434 case 2:
10435 fill_8();
10436 break;
10437
10438 case 3:
10439 fill2_4();
10440 break;
10441
10442 case 4:
10443 fill2_8();
10444 break;
10445 }
10446
10447 canfill = false;
10448 }
10449 }
10450 else
10451 draw(key[KEY_LSHIFT] || key[KEY_RSHIFT]);
10452 }
10453 else if (scr && lclick)
10454 {
10455 int32_t cx2 = (x-startxint)/mapscreen_single_scale;
10456 int32_t cy2 = (y-startyint)/mapscreen_single_scale;
10457
10458 // Move items
10459 if (scr->hasitem && active_visible_screen)
10460 {
10461 int32_t ix = scr->itemx + active_visible_screen->dx * 256;
10462 int32_t iy = scr->itemy + active_visible_screen->dy * 176;
10463
10464 if(cx2 >= ix && cx2 < ix+16 && cy2 >= iy && cy2 < iy+16)
10465 doxypos(scr->itemx, scr->itemy, 11, SNAP_HALF, SNAP_NONE, true, 0, 0, 16, 16);
10466 }
10467
10468 // Move FFCs
10469 int num_ffcs = scr->numFFC();
10470 for(int32_t i=num_ffcs-1; i>=0; i--)
10471 if(scr->ffcs[i].data !=0 && (scr->ffcs[i].layer >= CurrentLayer || (scr->ffcs[i].flags&ffc_overlay)))
10472 {
10473 int32_t ffx = scr->ffcs[i].x.getFloor() + active_visible_screen->dx * 256;
10474 int32_t ffy = scr->ffcs[i].y.getFloor() + active_visible_screen->dy * 176;
10475
10476 if(cx2 >= ffx && cx2 < ffx+(scr->ffTileWidth(i)*16) && cy2 >= ffy && cy2 < ffy+(scr->ffTileHeight(i)*16))
10477 {
10478 moveffc(i, cx2, cy2);
10479 break;
10480 }
10481 }
10482
10483 if(key[KEY_ALT]||key[KEY_ALTGR])
10484 {
10485 if (!draw_mapscr) return;
10486
10487 Combo=draw_mapscr->data[c];
10488 if(AutoBrush)
10489 BrushWidth = BrushHeight = 1;
10490 if(key[KEY_LSHIFT]||key[KEY_RSHIFT])
10491 CSet=draw_mapscr->cset[c];
10492 if(CHECK_CTRL_CMD)
10493 First[current_combolist]=scrollto_cmb(draw_mapscr->data[c]);
10494 }
10495 else if(CHECK_CTRL_CMD)
10496 {
10497 if(canfill)
10498 {
10499 switch(fill_type)
10500 {
10501 case 0:
10502 flood();
10503 break;
10504
10505 case 1:
10506 fill_4();
10507 break;
10508
10509 case 2:
10510 fill_8();
10511 break;
10512
10513 case 3:
10514 fill2_4();
10515 break;
10516
10517 case 4:
10518 fill2_8();
10519 break;
10520 }
10521
10522 canfill=false;
10523 }
10524 }
10525 else draw(key[KEY_LSHIFT] || key[KEY_RSHIFT]);
10526 }
10527 else if (scr && rclick)
10528 {
10529 ComboBrushPause=1;
10530 refresh(rMAP);
10531 restore_mouse();
10532 ComboBrushPause=0;
10533
10534 bool clickedffc = false;
10535
10536 // FFC right-click menu
10537 // This loop also serves to find the free ffc with the smallest slot number.
10538 int num_ffcs = scr->numFFC();
10539 uint32_t earliestfreeffc = num_ffcs;
10540 for(int32_t i=num_ffcs-1; i>=0; i--)
10541 {
10542 auto data = scr->ffcs[i].data;
10543 if(data==0)
10544 {
10545 if(i < earliestfreeffc)
10546 earliestfreeffc = i;
10547 continue;
10548 }
10549
10550 if(clickedffc || !(scr->valid&mVALID))
10551 continue;
10552
10553 if(data!=0 && (scr->ffcs[i].layer >= CurrentLayer || (scr->ffcs[i].flags&ffc_overlay)))
10554 {
10555 int32_t ffx = scr->ffcs[i].x.getFloor() + active_visible_screen->dx * 256;
10556 int32_t ffy = scr->ffcs[i].y.getFloor() + active_visible_screen->dy * 176;
10557 int32_t cx2 = (x-startxint)/mapscreen_single_scale;
10558 int32_t cy2 = (y-startyint)/mapscreen_single_scale;
10559
10560 if(cx2 >= ffx && cx2 < ffx+(scr->ffTileWidth(i)*16) && cy2 >= ffy && cy2 < ffy+(scr->ffTileHeight(i)*16))
10561 {
10562 NewMenu rcmenu
10563 {
10564 { "Copy FFC", [&](){Map.CopyFFC(active_visible_screen->screen, i);} },
10565 { "Paste FFC data", [&]()
10566 {
10567 bool didconfirm = false;
10568 AlertDialog("Confirm Paste",
10569 "Really replace the FFC with the data of the copied FFC?",
10570 [&](bool ret,bool)
10571 {
10572 if(ret)
10573 didconfirm = true;
10574 }).show();
10575 if(didconfirm)
10576 {
10577 auto set_ffc_data = Map.getCopyFFCData();
10578 set_ffc_data.x = scr->ffcs[i].x;
10579 set_ffc_data.y = scr->ffcs[i].y;
10580 Map.DoSetFFCCommand(Map.getCurrMap(), active_visible_screen->screen, i, set_ffc_data);
10581 }
10582 }, nullopt, Map.getCopyFFC() < 0 },
10583 { "Edit FFC", [&](){call_ffc_dialog(i, active_visible_screen->scr, active_visible_screen->screen);} },
10584 { "Clear FFC", [&]()
10585 {
10586 bool didconfirm = false;
10587 AlertDialog("Confirm Clear",
10588 "Really clear this Freeform Combo?",
10589 [&](bool ret,bool)
10590 {
10591 if(ret)
10592 didconfirm = true;
10593 }).show();
10594 if(didconfirm)
10595 {
10596 Map.DoSetFFCCommand(Map.getCurrMap(), active_visible_screen->screen, i, {
10597 .x = 0,
10598 .y = 0,
10599 .vx = 0,
10600 .vy = 0,
10601 .ax = 0,
10602 .ay = 0,
10603 .data = 0,
10604 .cset = 0,
10605 .delay = 0,
10606 .link = 0,
10607 .script = 0,
10608 .tw = 1,
10609 .th = 1,
10610 .ew = 16,
10611 .eh = 16,
10612 .flags = ffc_none,
10613 .initd = 0,
10614 });
10615 saved = false;
10616 }
10617 } },
10618 { "Snap to Grid", [&]()
10619 {
10620 int oldffx = scr->ffcs[i].x.getInt();
10621 int oldffy = scr->ffcs[i].y.getInt();
10622 int pos = COMBOPOS(oldffx,oldffy);
10623 int newffy = COMBOY(pos);
10624 int newffx = COMBOX(pos);
10625
10626 auto set_ffc_data = set_ffc_command::create_data(scr->ffcs[i]);
10627 set_ffc_data.x = newffx;
10628 set_ffc_data.y = newffy;
10629 Map.DoSetFFCCommand(Map.getCurrMap(), active_visible_screen->screen, i, set_ffc_data);
10630
10631 saved = false;
10632 } },
10633 };
10634 rcmenu.pop(x, y);
10635 clickedffc = true;
10636 break;
10637 }
10638 }
10639 }
10640
10641 // Combo right-click menu
10642 if(!clickedffc)
10643 {
10644 int warpindex = Map.warpindex(scr->data[c]);
10645 string txt_twarp_follow, txt_twarp_edit, txt_ffc_edit, txt_ffc_paste;
10646 bool show_ffcs = earliestfreeffc < MAXFFCS;
10647 bool dis_paste_ffc = Map.getCopyFFC() < 0;
10648 bool show_warps = warpindex > -1;
10649 bool show_warpback = Map.has_warpback();
10650 // FFC-specific options
10651 if(earliestfreeffc < MAXFFCS)
10652 {
10653 txt_ffc_edit = fmt::format("Edit New FFC {}",earliestfreeffc+1);
10654 if(Map.getCopyFFC()>-1)
10655 txt_ffc_paste = fmt::format("Paste FFC as FFC {}",earliestfreeffc+1);
10656 else
10657 txt_ffc_paste = "Paste FFC";
10658 }
10659
10660 if(warpindex > -1)
10661 {
10662 char letter = warpindex==4 ? 'R' : 'A'+warpindex;
10663 txt_twarp_follow = fmt::format("Follow Tile Warp {}",letter);
10664 txt_twarp_edit = fmt::format("Edit Tile Warp {}",letter);
10665 }
10666
10667 NewMenu draw_rc_menu
10668 {
10669 { "Select Combo", [&]()
10670 {
10671 Combo = draw_mapscr->data[c];
10672 if(AutoBrush)
10673 BrushWidth = BrushHeight = 1;
10674 }, nullopt, !draw_mapscr },
10675 { "Scroll to Combo", [&]()
10676 {
10677 First[current_combolist] = scrollto_cmb(draw_mapscr->data[c]);
10678 }, nullopt, !draw_mapscr },
10679 { "Edit Combo", [&]()
10680 {
10681 edit_combo(draw_mapscr->data[c],true,draw_mapscr->cset[c]);
10682 }, nullopt, !draw_mapscr },
10683 {},
10684 { "Replace All", [&](){replace(combo_pos);} },
10685 { "Draw Block", &draw_block_menu },
10686 { "Brush Settings ", &brush_menu },
10687 { "Set Fill Type ", &fill_menu },
10688 };
10689 if(show_warps || show_warpback)
10690 {
10691 draw_rc_menu.add_sep();
10692 if(show_warpback)
10693 draw_rc_menu.add({ "Warp Back", [&](){Map.warpback();} });
10694 if(show_warps)
10695 {
10696 draw_rc_menu.add({ txt_twarp_follow, [&](){follow_twarp(warpindex);} });
10697 draw_rc_menu.add({ txt_twarp_edit, [&](){edit_twarp(warpindex);} });
10698 }
10699 }
10700 if(show_ffcs)
10701 {
10702 draw_rc_menu.add_sep();
10703 draw_rc_menu.add({ txt_ffc_edit, [&]()
10704 {
10705 ffdata tempdat;
10706 // x, y are ints on ffdata (but ffc x, y are zfix), so *10000
10707 tempdat.x = ((int((x-startxint)/mapscreen_single_scale)&(~0x0007)) % 256) * 10000;
10708 tempdat.y = ((int((y-startyint)/mapscreen_single_scale)&(~0x0007)) % 176) * 10000;
10709 tempdat.data = Combo;
10710 tempdat.cset = CSet;
10711 call_ffc_dialog(earliestfreeffc, tempdat, active_visible_screen->scr, active_visible_screen->screen);
10712 } });
10713 draw_rc_menu.add({ txt_ffc_paste, [&]()
10714 {
10715 auto set_ffc_data = Map.getCopyFFCData();
10716 set_ffc_data.x = ((int((x-startxint)/mapscreen_single_scale)&(~0x0007)) % 256);
10717 set_ffc_data.y = ((int((y-startyint)/mapscreen_single_scale)&(~0x0007)) % 176);
10718 Map.DoSetFFCCommand(Map.getCurrMap(), active_visible_screen->screen, earliestfreeffc, set_ffc_data);
10719 }, nullopt, dis_paste_ffc });
10720 }
10721 draw_rc_menu.add_sep();
10722 draw_rc_menu.add({ "Screen", &rc_menu_screen });
10723 draw_rc_menu.pop(x,y);
10724 }
10725 }
10726 goto domouse_doneclick;
10727 }
10728
10729 //on the drawing mode button
10730 font = get_custom_font(CFONT_GUI);
10731 if(drawmode_btn.rect(x,y))
10732 {
10733 if(lclick)
10734 {
10735 if(do_text_button(drawmode_btn.x,drawmode_btn.y,drawmode_btn.w,drawmode_btn.h,dm_names[draw_mode]))
10736 onDrawingMode();
10737 }
10738 else if(rclick)
10739 drawing_mode_menu.pop(x,y);
10740 goto domouse_doneclick;
10741 }
10742 font=tfont;
10743
10744 //Squares
10745 //
10746 set_active_visible_screen(Map.CurrScr());
10747 {
10748 if(squarepanel_swap_btn.rect(x,y))
10749 {
10750 toggle_compact_sqr_mode();
10751 goto domouse_doneclick;
10752 }
10753 if(squarepanel_up_btn.rect(x,y))
10754 {
10755 cycle_compact_sqr(false);
10756 goto domouse_doneclick;
10757 }
10758 if(squarepanel_down_btn.rect(x,y))
10759 {
10760 cycle_compact_sqr(true);
10761 goto domouse_doneclick;
10762 }
10763
10764 bool do_dummyxy = false;
10765 bool dummymode = key[KEY_LSHIFT] || key[KEY_RSHIFT];
10766
10767 if(itemsqr_pos.rect(x,y))
10768 {
10769 if(dummymode) do_dummyxy = true;
10770 else
10771 {
10772 onItem();
10773
10774 if(!rclick && Map.CurrScr()->hasitem)
10775 doxypos(Map.CurrScr()->itemx,Map.CurrScr()->itemy,11,SNAP_HALF,SNAP_NONE);
10776 goto domouse_doneclick;
10777 }
10778 }
10779
10780 if(stairsqr_pos.rect(x,y))
10781 {
10782 if(dummymode) do_dummyxy = true;
10783 else
10784 {
10785 doxypos(Map.CurrScr()->stairx,Map.CurrScr()->stairy,14,SNAP_WHOLE);
10786 goto domouse_doneclick;
10787 }
10788 }
10789
10790 if(warparrival_pos.rect(x,y))
10791 {
10792 if(dummymode) do_dummyxy = true;
10793 else
10794 {
10795 if(get_qr(qr_NOARRIVALPOINT))
10796 {
10797 info_dsa("Arrival Square",
10798 "The arrival square cannot be used unless the QR 'Use Warp Return "
10799 "Points Only' under 'Quest->Options->Combos' is disabled."
10800 "\nGenerally, this square only exists for compatibility purposes, and is not used"
10801 " in creating new quests.",
10802 "dsa_warparrival");
10803 }
10804 else doxypos(Map.CurrScr()->warparrivalx,Map.CurrScr()->warparrivaly,10,SNAP_HALF,SNAP_NONE);
10805 goto domouse_doneclick;
10806 }
10807 }
10808
10809 if(flagsqr_pos.rect(x,y))
10810 {
10811 if(dummymode) do_dummyxy = true;
10812 else
10813 {
10814 onFlags();
10815 goto domouse_doneclick;
10816 }
10817 }
10818
10819 for(auto q = 0; q < 4; ++q)
10820 {
10821 if(warpret_pos[q].rect(x,y))
10822 {
10823 if(dummymode) do_dummyxy = true;
10824 else
10825 {
10826 doxypos(Map.CurrScr()->warpreturnx[q],Map.CurrScr()->warpreturny[q],9,SNAP_HALF,SNAP_NONE);
10827 goto domouse_doneclick;
10828 }
10829 }
10830 }
10831
10832 if(enemy_prev_pos.rect(x,y))
10833 {
10834 if(dummymode) do_dummyxy = true;
10835 else
10836 {
10837 onEnemies();
10838 goto domouse_doneclick;
10839 }
10840 }
10841
10842 if(do_dummyxy)
10843 {
10844 byte x = 0, y = 0;
10845 showxypos_dummy = true;
10846 doxypos(x,y,13,SNAP_HALF,SNAP_NONE);
10847 goto domouse_doneclick;
10848 }
10849 }
10850
10851 if(draw_mode==dm_alias)
10852 {
10853 for(int32_t j=0; j<num_combo_cols; ++j)
10854 {
10855 if(combolistscrollers[j].rectind(x,y)==0 && !mouse_down)
10856 {
10857 scrollup(j);
10858 goto domouse_doneclick;
10859 }
10860 else if(combolistscrollers[j].rectind(x,y)==1 && !mouse_down)
10861 {
10862 scrolldown(j);
10863 goto domouse_doneclick;
10864 }
10865 else if(comboaliaslist[j].rect(x,y))
10866 {
10867 select_comboa(j);
10868
10869 if(rclick && comboaliaslist[j].rect(gui_mouse_x(),gui_mouse_y()))
10870 popup_cpane_rc(x, y);
10871 goto domouse_doneclick;
10872 }
10873 }
10874 }
10875 else if(draw_mode==dm_cpool)
10876 {
10877 for(int32_t j=0; j<num_combo_cols; ++j)
10878 {
10879 if(combolistscrollers[j].rectind(x,y)==0 && !mouse_down)
10880 {
10881 scrollup(j);
10882 goto domouse_doneclick;
10883 }
10884 else if(combolistscrollers[j].rectind(x,y)==1 && !mouse_down)
10885 {
10886 scrolldown(j);
10887 goto domouse_doneclick;
10888 }
10889 else if(comboaliaslist[j].rect(x,y))
10890 {
10891 select_combop(j);
10892
10893 if(rclick && comboaliaslist[j].rect(gui_mouse_x(),gui_mouse_y()))
10894 popup_cpane_rc(x, y);
10895 goto domouse_doneclick;
10896 }
10897 }
10898 }
10899 else if (draw_mode == dm_auto)
10900 {
10901 for (int32_t j = 0; j < num_combo_cols; ++j)
10902 {
10903 if (combolistscrollers[j].rectind(x, y) == 0 && !mouse_down)
10904 {
10905 scrollup(j);
10906 goto domouse_doneclick;
10907 }
10908 else if (combolistscrollers[j].rectind(x, y) == 1 && !mouse_down)
10909 {
10910 scrolldown(j);
10911 goto domouse_doneclick;
10912 }
10913 else if (comboaliaslist[j].rect(x, y))
10914 {
10915 select_autocombo(j);
10916
10917 if(rclick && comboaliaslist[j].rect(gui_mouse_x(),gui_mouse_y()))
10918 popup_cpane_rc(x, y);
10919 goto domouse_doneclick;
10920 }
10921 }
10922 }
10923 else
10924 {
10925 for(int32_t j=0; j<num_combo_cols; ++j)
10926 {
10927 if(combolistscrollers[j].rectind(x,y)==0 && !mouse_down)
10928 {
10929 scrollup(j);
10930 goto domouse_doneclick;
10931 }
10932 else if(combolistscrollers[j].rectind(x,y)==1 && !mouse_down)
10933 {
10934 scrolldown(j);
10935 goto domouse_doneclick;
10936 }
10937 else if(combolist[j].rect(x,y))
10938 {
10939 select_combo(j);
10940
10941 if(rclick && combolist[j].rect(gui_mouse_x(),gui_mouse_y()))
10942 popup_cpane_rc(x, y);
10943 goto domouse_doneclick;
10944 }
10945 }
10946 }
10947
10948 //on the favorites list
10949 if(favorites_list.rect(x,y))
10950 {
10951 if(lclick)
10952 {
10953 int32_t f=favorites_list.rectind(x,y);
10954 int32_t row=f/favorites_list.w;
10955 int32_t col=f%favorites_list.w;
10956 f = (row*FAVORITECOMBO_PER_ROW)+col;
10957 int32_t fp = f + FAVORITECOMBO_PER_PAGE * FavoriteComboPage;
10958
10959 bool dmcond = favorite_combos[fp] < 0;
10960 if((key[KEY_LSHIFT] || key[KEY_RSHIFT] || dmcond) && !(CHECK_CTRL_CMD))
10961 {
10962 int32_t tempcb=ComboBrush;
10963 ComboBrush=0;
10964
10965 while(gui_mouse_b())
10966 {
10967 x=gui_mouse_x();
10968 y=gui_mouse_y();
10969
10970 switch(draw_mode)
10971 {
10972 case dm_alias:
10973 if (favorite_combos[fp] != combo_apos || favorite_combo_modes[fp] != dm_alias)
10974 {
10975 favorite_combo_modes[fp] = dm_alias;
10976 favorite_combos[fp] = combo_apos;
10977 saved = false;
10978 }
10979 break;
10980 case dm_cpool:
10981 if (favorite_combos[fp] != combo_pool_pos || favorite_combo_modes[fp] != dm_cpool)
10982 {
10983 favorite_combo_modes[fp] = dm_cpool;
10984 favorite_combos[fp] = combo_pool_pos;
10985 saved = false;
10986 }
10987 break;
10988 case dm_auto:
10989 if (favorite_combos[fp] != combo_auto_pos || favorite_combo_modes[fp] != dm_auto)
10990 {
10991 favorite_combo_modes[fp] = dm_auto;
10992 favorite_combos[fp] = combo_auto_pos;
10993 saved = false;
10994 }
10995 break;
10996 default:
10997 if (favorite_combos[fp] != Combo || favorite_combo_modes[fp] != dm_normal)
10998 {
10999 if (BrushWidth > 1 || BrushHeight > 1)
11000 {
11001 add_favorite_combo_block(f, Combo, key[KEY_LSHIFT] || key[KEY_RSHIFT]);
11002 break;
11003 }
11004 favorite_combo_modes[fp] = dm_normal;
11005 favorite_combos[fp] = Combo;
11006 saved = false;
11007 }
11008 }
11009
11010 custom_vsync();
11011 refresh(rALL | rFAVORITES);
11012 }
11013
11014 ComboBrush=tempcb;
11015 }
11016 else if(CHECK_CTRL_CMD)
11017 {
11018 int32_t tempcb=ComboBrush;
11019 ComboBrush=0;
11020
11021 while(gui_mouse_b())
11022 {
11023 x=gui_mouse_x();
11024 y=gui_mouse_y();
11025
11026 if(favorite_combos[fp]!=-1)
11027 {
11028 favorite_combo_modes[fp] = dm_normal;
11029 favorite_combos[fp]=-1;
11030 saved=false;
11031 }
11032
11033 custom_vsync();
11034 refresh(rALL | rFAVORITES);
11035 }
11036
11037 ComboBrush=tempcb;
11038 }
11039 else if(key[KEY_ALT] || key[KEY_ALTGR])
11040 {
11041 if(select_favorite())
11042 {
11043 switch(favorite_combo_modes[fp])
11044 {
11045 case dm_alias:
11046 combo_alistpos[current_comboalist]=scrollto_alias(combo_apos);
11047 break;
11048 case dm_cpool:
11049 combo_pool_listpos[current_cpoollist] = scrollto_cpool(combo_pool_pos);
11050 break;
11051 case dm_auto:
11052 combo_auto_listpos[current_cautolist] = scrollto_cauto(combo_auto_pos);
11053 break;
11054 default:
11055 First[current_combolist]=scrollto_cmb(Combo);
11056 }
11057 }
11058 }
11059 else
11060 {
11061 select_favorite();
11062 }
11063 }
11064 else if(rclick)
11065 {
11066 bool valid=select_favorite();
11067
11068 if(valid)
11069 {
11070 int f = favorites_list.rectind(x,y);
11071 int row = f/favorites_list.w;
11072 int col = f%favorites_list.w;
11073 f = (row*FAVORITECOMBO_PER_ROW) + col + (FAVORITECOMBO_PER_PAGE * FavoriteComboPage);
11074 popup_favorites_rc(f, x, y);
11075 }
11076 }
11077 goto domouse_doneclick;
11078 }
11079
11080 //on the commands buttons
11081 int32_t cmd = commands_list.rectind(x,y);
11082 if(cmd > -1)
11083 {
11084 uint hkey = favorite_commands[cmd];
11085 bool shift=(key[KEY_LSHIFT] || key[KEY_RSHIFT]);
11086 bool ctrl=(CHECK_CTRL_CMD);
11087 bool alt=(key[KEY_ALT] || key[KEY_ALTGR]);
11088 bool dis = disabled_hotkey(hkey);
11089 auto& btn = commands_list.subsquare(cmd);
11090 if(!dis||rclick||shift||ctrl||alt)
11091 {
11092 FONT *tfont=font;
11093 font=get_custom_font(CFONT_FAVCMD);
11094 if(do_layer_button_reset(btn.x,btn.y,btn.w,btn.h,
11095 get_hotkey_name(hkey),
11096 selected_hotkey(hkey)?D_SELECTED:0,
11097 true))
11098 {
11099 font=tfont;
11100 if(alt)
11101 {
11102 show_hotkey_info(hkey);
11103 }
11104 else if(ctrl)
11105 {
11106 write_fav_command(cmd,0);
11107 }
11108 else if(rclick || shift || hkey==ZQKEY_NULL_KEY)
11109 {
11110 if(auto newkey = select_fav_command())
11111 write_fav_command(cmd,*newkey);
11112 }
11113 else
11114 {
11115 run_hotkey(hkey);
11116 }
11117 }
11118
11119 font=tfont;
11120 }
11121 goto domouse_doneclick;
11122 }
11123 }
11124
11125 domouse_doneclick:
11126 mouse_down |= mb&3;
11127
11128 if(mouse_z!=0)
11129 {
11130 int32_t z=0;
11131
11132 for(int32_t j=0; j<num_combo_cols; ++j)
11133 {
11134 z=abs(mouse_z);
11135
11136 if(key[KEY_ALT]||key[KEY_ALTGR])
11137 {
11138 z*=combolist[j].h;
11139 }
11140
11141
11142 if(draw_mode == dm_alias)
11143 {
11144 if(comboaliaslist[j].rect(x,y))
11145 {
11146 if(mouse_z<0) //scroll down
11147 {
11148 combo_alistpos[current_comboalist] = zc_min(MAXCOMBOALIASES - comboaliaslist[j].w*comboaliaslist[j].h,
11149 combo_alistpos[current_comboalist]+comboaliaslist[j].w*z);
11150 }
11151 else //scroll up
11152 {
11153 if(combo_alistpos[current_comboalist]>0)
11154 {
11155 combo_alistpos[current_comboalist]-=zc_min(combo_alistpos[current_comboalist],comboaliaslist[j].w*z);
11156 }
11157 }
11158 goto domouse_donez;
11159 }
11160 }
11161 else if(draw_mode == dm_cpool)
11162 {
11163 if(comboaliaslist[j].rect(x,y))
11164 {
11165 if(mouse_z<0) //scroll down
11166 {
11167 combo_pool_listpos[current_cpoollist] = zc_min(MAXCOMBOPOOLS - comboaliaslist[j].w*comboaliaslist[j].h,
11168 combo_pool_listpos[current_cpoollist]+comboaliaslist[j].w*z);
11169 }
11170 else //scroll up
11171 {
11172 if(combo_pool_listpos[current_cpoollist]>0)
11173 {
11174 combo_pool_listpos[current_cpoollist]-=zc_min(combo_pool_listpos[current_cpoollist],comboaliaslist[j].w*z);
11175 }
11176 }
11177 goto domouse_donez;
11178 }
11179 }
11180 else if (draw_mode == dm_auto)
11181 {
11182 if (comboaliaslist[j].rect(x, y))
11183 {
11184 if (mouse_z < 0) //scroll down
11185 {
11186 combo_auto_listpos[current_cautolist] = zc_min(MAXAUTOCOMBOS - comboaliaslist[j].w * comboaliaslist[j].h,
11187 combo_auto_listpos[current_cautolist] + comboaliaslist[j].w * z);
11188 }
11189 else //scroll up
11190 {
11191 if (combo_auto_listpos[current_cautolist] > 0)
11192 {
11193 combo_auto_listpos[current_cautolist] -= zc_min(combo_auto_listpos[current_cautolist], comboaliaslist[j].w * z);
11194 }
11195 }
11196 goto domouse_donez;
11197 }
11198 }
11199 else
11200 {
11201 if(combolist[j].rect(x,y))
11202 {
11203 if(mouse_z<0) //scroll down
11204 {
11205 First[current_combolist] = zc_min(MAXCOMBOS-combolist[j].w*combolist[j].h,
11206 First[current_combolist] + combolist[j].w*z);
11207 }
11208 else //scroll up
11209 {
11210 if(First[current_combolist]>0)
11211 {
11212 First[current_combolist]-=zc_min(First[current_combolist],combolist[j].w*z);
11213 }
11214 }
11215 goto domouse_donez;
11216 }
11217 }
11218 }
11219
11220 z=abs(mouse_z);
11221
11222 if(real_mini.rect(x,y))
11223 {
11224 for(int32_t i=0; i<z; ++i)
11225 {
11226 if(mouse_z>0) onIncMap();
11227 else onDecMap();
11228 }
11229 goto domouse_donez;
11230 }
11231
11232 if(is_compact && compact_square_panels
11233 && squares_panel.rect(x,y))
11234 {
11235 cycle_compact_sqr(mouse_z < 0);
11236 goto domouse_donez;
11237 }
11238 domouse_donez:
11239 position_mouse_z(0);
11240 }
11241 font = tfont;
11242 active_visible_screen = nullptr;
11243 }
11244
11245 int32_t d_viewpal_proc(int32_t msg, DIALOG *d, int32_t c)
11246 {
11247 int32_t ret = d_bitmap_proc(msg, d, c);
11248 char* buf = (char*)d->dp2; //buffer to store the color code in
11249 DIALOG* d2 = (DIALOG*)d->dp3; //DIALOG* to update the text proc
11250 if(!buf)
11251 return ret;
11252 switch(msg)
11253 {
11254 case MSG_IDLE:
11255 case MSG_GOTMOUSE:
11256 case MSG_LOSTMOUSE:
11257 break;
11258 default:
11259 return ret;
11260 }
11261 char t[16];
11262 memcpy(t, buf, 16);
11263 int32_t x = gui_mouse_x() - d->x;
11264 int32_t y = gui_mouse_y() - d->y;
11265 if(msg != MSG_LOSTMOUSE && isinRect(x, y, 0, 0, d->w-1, d->h-1))
11266 {
11267 float palscale = 1.5;
11268 for(int32_t i = 0; i<256; ++i)
11269 if(isinRect(x,y,(int32_t)(((i&31)<<3)*palscale),(int32_t)(((i&0xE0)>>2)*palscale), (int32_t)((((i&31)<<3)+7)*palscale),(int32_t)((((i&0xE0)>>2)+7)*palscale)))
11270 {
11271 sprintf(buf, "0x%02X (%03d) ", i, i); //Extra spaces to increase drawn width, so it draws the blank area
11272 break;
11273 }
11274 }
11275 else memset(buf, ' ', 15);
11276 if(strcmp(buf, t) && d2 && d2->proc == jwin_text_proc && d2->dp == d->dp2)
11277 object_message(d2, MSG_DRAW, 0);
11278 return ret;
11279 }
11280
11281 static DIALOG showpal_dlg[] =
11282 {
11283 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
11284 { jwin_win_proc, 24, 68, 272, 119, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "View Palette", NULL, NULL },
11285 { jwin_frame_proc, 30, 76+16, 260, 68, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
11286 { d_viewpal_proc, 32, 76+18, 256, 64, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
11287 { jwin_text_proc, 32+8,76+18+66, 20, 8, vc(11), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
11288 { jwin_button_proc, 130, 144+18, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
11289 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
11290 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
11291 };
11292
11293 int32_t onShowPal()
11294 {
11295 float palscale = 1.5;
11296
11297 BITMAP *palbmp = create_bitmap_ex(8,(int32_t)(256*palscale),(int32_t)(64*palscale));
11298
11299 if(!palbmp)
11300 return D_O_K;
11301 clear_to_color(palbmp,jwin_pal[jcBOX]); //If not cleared, random static appears between swatches! -E
11302 showpal_dlg[0].dp2=get_zc_font(font_lfont);
11303
11304 for(int32_t i=0; i<256; i++)
11305 rectfill(palbmp,(int32_t)(((i&31)<<3)*palscale),(int32_t)(((i&0xE0)>>2)*palscale), (int32_t)((((i&31)<<3)+7)*palscale),(int32_t)((((i&0xE0)>>2)+7)*palscale),i);
11306 showpal_dlg[2].dp=(void *)palbmp;
11307 char buf[16] = {0};
11308 showpal_dlg[2].dp2=(void *)buf;
11309 showpal_dlg[2].dp3=(void *)&(showpal_dlg[3]);
11310 showpal_dlg[3].dp=(void *)buf;
11311 showpal_dlg[3].dp2=(void *)get_zc_font(font_deffont);
11312
11313 large_dialog(showpal_dlg);
11314 do_zqdialog(showpal_dlg,2);
11315 destroy_bitmap(palbmp);
11316 return D_O_K;
11317 }
11318
11319 static DIALOG csetfix_dlg[] =
11320 {
11321 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
11322 { jwin_win_proc, 72, 80, 176+1, 96+1, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "CSet Fix", NULL, NULL },
11323 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
11324 { jwin_radio_proc, 104+22, 108, 80+1, 8+1, vc(14), vc(1), 0, 0, 0, 0, (void *) "Full Screen", NULL, NULL },
11325 { jwin_radio_proc, 104+22, 118+2, 80+1, 8+1, vc(14), vc(1), 0, D_SELECTED, 0, 0, (void *) "Dungeon Floor", NULL, NULL },
11326 { d_dummy_proc, 120, 128, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
11327 { jwin_check_proc, 104+22, 128+4, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, (void *) "All Layers", NULL, NULL },
11328 { jwin_button_proc, 90, 152, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
11329 { jwin_button_proc, 170, 152, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
11330 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
11331 };
11332
11333 int32_t onCSetFix()
11334 {
11335 restore_mouse();
11336 csetfix_dlg[0].dp2=get_zc_font(font_lfont);
11337 int32_t s=2,x2=14,y2=9;
11338
11339 large_dialog(csetfix_dlg);
11340
11341 if(do_zqdialog(csetfix_dlg,-1)==6)
11342 {
11343 if(csetfix_dlg[2].flags&D_SELECTED)
11344 {
11345 s=0;
11346 x2=16;
11347 y2=11;
11348 }
11349
11350 if(csetfix_dlg[5].flags&D_SELECTED)
11351 {
11352 /*
11353 int32_t drawmap, drawscr;
11354 if (CurrentLayer==0)
11355 {
11356 drawmap=Map.getCurrMap();
11357 drawscr=Map.getCurrScr();
11358 }
11359 else
11360 {
11361 drawmap=Map.CurrScr()->layermap[CurrentLayer-1]-1;
11362 drawscr=Map.CurrScr()->layerscreen[CurrentLayer-1];
11363 }
11364 mapscr* draw_mapscr = Map.AbsoluteScr(drawmap, drawscr);
11365 if(!draw_mapscr) return;
11366 saved=false;
11367 Map.Ugo();
11368
11369 if(!(draw_mapscr->valid&mVALID))
11370 {
11371 Map.CurrScr()->valid|=mVALID;
11372 draw_mapscr->valid|=mVALID;
11373 Map.setcolor(Color);
11374 }
11375 for(int32_t i=0; i<176; i++)
11376 {
11377 draw_mapscr->data[i]=Combo;
11378 draw_mapscr->cset[i]=CSet;
11379 }
11380 refresh(rMAP+rSCRMAP);
11381 */
11382 }
11383
11384 Map.StartListCommand();
11385 for(int32_t y=s; y<y2; y++)
11386 {
11387 for(int32_t x=s; x<x2; x++)
11388 {
11389 Map.DoSetComboCommand(Map.getCurrMap(), Map.getCurrScr(), (y<<4)+x, -1, CSet);
11390 }
11391 }
11392 Map.FinishListCommand();
11393
11394 refresh(rMAP);
11395 saved = false;
11396 }
11397
11398 return D_O_K;
11399 }
11400 static bool doAllSolidWater()
11401 {
11402 for(int32_t i=0; i < MAXCOMBOS; ++i)
11403 {
11404 if(combo_class_buf[combobuf[i].type].water!=0)
11405 {
11406 combobuf[i].walk |= 0x0F; //Solid
11407 }
11408 }
11409 return true;
11410 }
11411 static bool doNoSolidWater()
11412 {
11413 for(int32_t i=0; i < MAXCOMBOS; ++i)
11414 {
11415 if(combo_class_buf[combobuf[i].type].water!=0)
11416 {
11417 combobuf[i].walk &= ~0x0F; //Non-solid
11418 }
11419 }
11420 return true;
11421 }
11422 int32_t onWaterSolidity()
11423 {
11424 AlertFuncDialog("Water Conversion",
11425 "Forcibly set the solidity of all 'Liquid' combos in the quest?",
11426 ""
11427 ).add_buttons(2,
11428 { "Solid", "Non-Solid", "Cancel" },
11429 { doAllSolidWater, doNoSolidWater, nullptr }
11430 ).show();
11431 return D_O_K;
11432 }
11433
11434 static bool doAllEffectSquare()
11435 {
11436 for(int32_t i=0; i < MAXCOMBOS; ++i)
11437 {
11438 combobuf[i].walk |= 0xF0; //Effect
11439 }
11440 return true;
11441 }
11442 static bool doBlankEffectSquare()
11443 {
11444 for(int32_t i=0; i < MAXCOMBOS; ++i)
11445 {
11446 if(combobuf[i].is_blank(true))
11447 {
11448 combobuf[i].walk |= 0xF0; //Effect
11449 }
11450 }
11451 return true;
11452 }
11453
11454 int32_t onEffectFix()
11455 {
11456 AlertFuncDialog("Effect Square Conversion",
11457 "Forcibly fill the green effect square of all combos in the quest?",
11458 ""
11459 ).add_buttons(2,
11460 { "All", "Blank Only", "Cancel" },
11461 { doAllEffectSquare, doBlankEffectSquare, nullptr }
11462 ).show();
11463 return D_O_K;
11464 }
11465
11466 static bool clear_green_arrival_squares()
11467 {
11468 for(mapscr& scr : TheMaps)
11469 {
11470 if(!scr.valid) continue;
11471 scr.warparrivalx = 0;
11472 scr.warparrivaly = 0;
11473 }
11474 set_qr(qr_NOARRIVALPOINT, true);
11475 return true;
11476 }
11477
11478 static bool replace_green_arrival_squares()
11479 {
11480 // Check for conflicts first
11481 bool has_conflicts = false;
11482
11483 for(mapscr& scr : TheMaps)
11484 {
11485 if(!scr.valid) continue;
11486 if(!(scr.warparrivalx || scr.warparrivaly)) continue;
11487 if(scr.warpreturnx[0] || scr.warpreturny[0])
11488 {
11489 has_conflicts = true;
11490 break;
11491 }
11492 }
11493
11494 enum
11495 {
11496 NOT_ASKED = -1,
11497 MODE_FORCE, MODE_IGNORE, MODE_FIND_IGNORE, MODE_FIND_FORCE, MODE_CANCEL
11498 };
11499 int mode = NOT_ASKED;
11500
11501 if(has_conflicts)
11502 {
11503 AlertFuncDialog("Handle Conflicts",
11504 "Warp Square A is not available for all screens that have arrival squares."
11505 " How should this be handled? (See '?' for more info)",
11506 "Overwrite A: Replace the existing warp return square A with the position of the green arrival square"
11507 "\nIgnore: Do nothing if warp return square A exists"
11508 "\nFind Space or Ignore: Choose another, unused, square to set to the position of the green arrival square."
11509 " If none are unused, 'Ignore' instead."
11510 "\nFind Space or Overwrite: Choose another, unused square to set to the position of the green arrival square."
11511 " If none are unused, 'Overwrite A' instead."
11512 "\nCancel: Don't do anything"
11513 ).add_buttons(1,
11514 { "Overwrite A", "Ignore", "Find Space or Ignore", "Find Space or Overwrite A", "Cancel" },
11515 mode
11516 ).show();
11517 if(mode == NOT_ASKED || mode == MODE_CANCEL)
11518 return false;
11519 }
11520 for(mapscr& scr : TheMaps)
11521 {
11522 if(!scr.valid) continue;
11523 if(!(scr.warparrivalx || scr.warparrivaly)) continue;
11524 int indx = 0;
11525 if(scr.warpreturnx[0] || scr.warpreturny[0])
11526 {
11527 if(mode == MODE_IGNORE) continue; // Warp A not free, so ignore
11528 if(mode != MODE_FORCE)
11529 {
11530 for(int q = 1; q < 4; ++q)
11531 {
11532 if(scr.warpreturnx[q] || scr.warpreturny[q])
11533 continue;
11534 indx = q; // Use this warp, since it's free
11535 break;
11536 }
11537 if(indx == 0 && mode == MODE_FIND_IGNORE)
11538 continue; // Nothing free, so ignore
11539 }
11540 }
11541 scr.warpreturnx[indx] = scr.warparrivalx;
11542 scr.warpreturny[indx] = scr.warparrivaly;
11543 scr.warparrivalx = 0;
11544 scr.warparrivaly = 0;
11545 }
11546 set_qr(qr_NOARRIVALPOINT, true);
11547 return true;
11548 }
11549
11550 int32_t onRemoveOldArrivalSquare()
11551 {
11552 AlertFuncDialog("Arrival Square Removal",
11553 "Clear the old green 'Arrival' squares for the whole quest?"
11554 "\n(There will be no further confirmation, and this operation cannot be undone)",
11555 ""
11556 ).add_buttons(2,
11557 { "Replace With Blue Return Square", "Clear Completely", "Cancel" },
11558 { replace_green_arrival_squares, clear_green_arrival_squares, nullptr }
11559 ).show();
11560 return D_O_K;
11561 }
11562
11563 byte* getPalPointer(int32_t pal, int32_t cset)
11564 {
11565 if (pal < 0) return colordata + CSET(cset)*3;
11566 byte* ret = colordata + CSET(pal*pdLEVEL+poLEVEL)*3;
11567 switch(cset)
11568 {
11569 case 2: case 3: case 4:
11570 return ret + CSET(cset-2)*3;
11571 case 9:
11572 return ret + CSET(3)*3;
11573 case 1:
11574 return ret + CSET(13)*3;
11575 case 5:
11576 return ret + CSET(14)*3;
11577 case 7:
11578 return ret + CSET(15)*3;
11579 case 8:
11580 return ret + CSET(16)*3;
11581 }
11582 return NULL;
11583 }
11584
11585 void copyCSet(int32_t destpal, int32_t destcset, int32_t srcpal, int32_t srccset)
11586 {
11587 byte* dest = getPalPointer(destpal, destcset);
11588 byte* src = getPalPointer(srcpal, srccset);
11589 if (dest && src)
11590 {
11591 memcpy(dest, src, 16*3);
11592 }
11593 }
11594
11595 void setColorPalette(int32_t flags, int32_t lowpal, int32_t highpal)
11596 {
11597 for (auto q = lowpal; q <= highpal; ++q)
11598 {
11599 for (auto c = 0; c < 12; ++c)
11600 {
11601 if (!(flags&(1<<c))) continue;
11602 copyCSet(q, c, -1, c);
11603 }
11604 }
11605 }
11606
11607 void setPitDamage(int32_t flags, int32_t lowcombo, int32_t highcombo, int32_t damage)
11608 {
11609 for(int32_t i=lowcombo; i < highcombo; ++i)
11610 {
11611 if((combobuf[i].type == cPITFALL && (flags & (1<<0)))
11612 || (combobuf[i].type == cWATER && !(combobuf[i].usrflags & (1<<0)) && (flags & (1<<1)))
11613 || (combobuf[i].type == cWATER && (combobuf[i].usrflags & (1<<0)) && (flags & (1<<2))))
11614 {
11615 if ((combobuf[i].type != cPITFALL || (flags & (1<<9)) || !(combobuf[i].usrflags & (1<<0)))
11616 && ((flags & (1<<8)) || combobuf[i].attributes[0] == 0))
11617 combobuf[i].attributes[0] = damage*10000;
11618 }
11619 }
11620 }
11621
11622 static DIALOG template_dlg[] =
11623 {
11624 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
11625 { jwin_win_proc, 72, 80, 176+1, 116+1, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "NES Dungeon Template", NULL, NULL },
11626 { d_comboframe_proc, 178, 122+3, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
11627 { d_combo_proc, 180, 124+3, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
11628 // { d_bitmap_proc, 180, 104, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
11629 { jwin_radio_proc, 104+33, 128+3, 64+1, 8+1, vc(14), vc(1), 0, D_SELECTED, 0, 0, (void *) "Floor:", NULL, NULL },
11630 { jwin_radio_proc, 104+33, 148+3, 64+1, 8+1, vc(14), vc(1), 0, 0, 0, 0, (void *) "No Floor", NULL, NULL },
11631 { jwin_button_proc, 90, 172, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
11632 { jwin_button_proc, 170, 172, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
11633 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
11634 { jwin_text_proc, 104, 102, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "This copies the contents of", NULL, NULL },
11635 { jwin_text_proc, 104, 112, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "screen 83 of the current map.", NULL, NULL },
11636 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
11637 };
11638
11639 int32_t onTemplate()
11640 {
11641 static bool donethis=false;
11642
11643 if(!donethis||!(key[KEY_LSHIFT]||key[KEY_RSHIFT]))
11644 {
11645 template_dlg[2].d1=Combo;
11646 template_dlg[2].fg=CSet;
11647 donethis=true;
11648 }
11649
11650 restore_mouse();
11651
11652 if(Map.getCurrScr()==TEMPLATE)
11653 return D_O_K;
11654
11655 // BITMAP *floor_bmp = create_bitmap_ex(8,16,16);
11656 // if(!floor_bmp) return D_O_K;
11657 template_dlg[0].dp2=get_zc_font(font_lfont);
11658 // put_combo(floor_bmp,0,0,Combo,CSet,0,0);
11659 // template_dlg[2].dp=floor_bmp;
11660
11661 large_dialog(template_dlg);
11662
11663 if(do_zqdialog(template_dlg,-1)==5)
11664 {
11665 saved=false;
11666 int screen = active_visible_screen ? active_visible_screen->screen : Map.getCurrScr();
11667 Map.DoTemplateCommand((template_dlg[3].flags==D_SELECTED) ? template_dlg[2].d1 : -1, template_dlg[2].fg, screen);
11668 refresh(rMAP+rSCRMAP);
11669 }
11670
11671 // destroy_bitmap(floor_bmp);
11672 return D_O_K;
11673 }
11674
11675 int32_t d_sel_scombo_proc(int32_t msg, DIALOG *d, int32_t c)
11676 {
11677 //these are here to bypass compiler warnings about unused arguments
11678 c=c;
11679
11680 switch(msg)
11681 {
11682 case MSG_CLICK:
11683 while(gui_mouse_b())
11684 {
11685 int32_t x = zc_min(zc_max(gui_mouse_x() - d->x,0)>>4, 15);
11686 int32_t y = zc_min(zc_max(gui_mouse_y() - d->y,0)&0xF0, 160);
11687
11688 if(x+y != d->d1)
11689 {
11690 d->d1 = x+y;
11691 custom_vsync();
11692 d_sel_scombo_proc(MSG_DRAW,d,0);
11693 }
11694 }
11695
11696 break;
11697
11698 case MSG_DRAW:
11699 {
11700 blit((BITMAP*)(d->dp),screen,0,0,d->x,d->y,d->w,d->h);
11701 int32_t x = d->x + (((d->d1)&15)<<4);
11702 int32_t y = d->y + ((d->d1)&0xF0);
11703 rect(screen,x,y,x+15,y+15,vc(15));
11704 }
11705 break;
11706 }
11707
11708 return D_O_K;
11709 }
11710
11711 static DIALOG cflag_dlg[] =
11712 {
11713 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
11714 12 { jwin_win_proc, 60-12, 40, 200+24, 148, vc(14), vc(1), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
11715 12 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
11716 12 { jwin_abclist_proc, 72-12-4, 60+4, 176+24+8, 92+3, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, D_EXIT, 0, 0, NULL, NULL, NULL },
11717 12 { jwin_button_proc, 70, 163, 51, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
11718 12 { jwin_button_proc, 190, 163, 51, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
11719 12 { jwin_button_proc, 130, 163, 51, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Help", NULL, NULL },
11720 12 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
11721 };
11722
11723
11724 void questrev_help()
11725 {
11726 jwin_alert("Help","The revision number of your quest.",NULL,NULL,"O&K",NULL,'k',16,get_zc_font(font_lfont));
11727 }
11728
11729 void questminrev_help()
11730 {
11731 jwin_alert("Help","If a player's saved game was from a revision less than the minimum", "revision, they have to restart from the beginning.", "This is useful if you make major changes to your quest.","O&K",NULL,'k',16,get_zc_font(font_lfont));
11732 }
11733
11734 int32_t select_cflag(const char *prompt,int32_t flag)
11735 {
11736 cflag_dlg[0].dp=(void *)prompt;
11737 cflag_dlg[0].dp2=get_zc_font(font_lfont);
11738 GUI::ListData ld = GUI::ZCListData::mapflag(numericalFlags, true);
11739 ListData select_cflag_list = ld.getJWin(&font);
11740 int32_t index = ld.findIndex(flag);
11741 cflag_dlg[2].d1=index;
11742 cflag_dlg[2].dp=(void *) &select_cflag_list;
11743
11744 large_dialog(cflag_dlg);
11745
11746 int32_t ret;
11747
11748 do
11749 {
11750 ret=do_zqdialog(cflag_dlg,2);
11751
11752 if(ret==5)
11753 {
11754 cflag_help(ld.getValue(cflag_dlg[2].d1));
11755 }
11756 }
11757 while(ret==5);
11758
11759 if(ret==0||ret==4)
11760 {
11761 position_mouse_z(0);
11762 return -1;
11763 }
11764
11765 return ld.getValue(cflag_dlg[2].d1);
11766 }
11767
11768 int32_t select_flag(int32_t &f)
11769 {
11770 int32_t ret=select_cflag("Flag Type",f);
11771
11772 if(ret>=0)
11773 {
11774 f=ret;
11775 return true;
11776 }
11777
11778 return false;
11779 }
11780
11781 int32_t d_scombo_proc(int32_t msg,DIALOG *d,int32_t c)
11782 {
11783 //these are here to bypass compiler warnings about unused arguments
11784 c=c;
11785
11786 switch(msg)
11787 {
11788 case MSG_CLICK:
11789 {
11790 int32_t c2=d->d1;
11791 int32_t cs=d->fg;
11792 int32_t f=d->d2;
11793
11794 if(d->bg==1 || (CHECK_CTRL_CMD))
11795 {
11796 while(gui_mouse_b())
11797 {
11798 /* do nothing */
11799 rest(1);
11800 }
11801
11802 if(select_flag(f))
11803 {
11804 d->d2=f;
11805
11806 }
11807 }
11808 else if(key[KEY_LSHIFT])
11809 {
11810 if(gui_mouse_b()&1)
11811 {
11812 d->d1++;
11813
11814 if(d->d1>=MAXCOMBOS) d->d1=0;
11815 }
11816 else if(gui_mouse_b()&2)
11817 {
11818 d->d1--;
11819
11820 if(d->d1<0) d->d1=MAXCOMBOS-1;
11821 }
11822 }
11823 else if(key[KEY_RSHIFT])
11824 {
11825 if(gui_mouse_b()&1)
11826 {
11827 d->fg++;
11828
11829 if(d->fg>11) d->fg=0;
11830 }
11831 else if(gui_mouse_b()&2)
11832 {
11833 d->fg--;
11834
11835 if(d->fg<0) d->fg=11;
11836 }
11837 }
11838 else if(key[KEY_ALT])
11839 {
11840 if(gui_mouse_b()&1)
11841 {
11842 d->d1 = Combo;
11843 d->fg = CSet;
11844 }
11845 }
11846 else
11847 {
11848 if(select_combo_2(c2, cs))
11849 {
11850 d->d1=c2;
11851 d->fg=cs;
11852 }
11853 }
11854
11855 return D_REDRAW;
11856 }
11857 break;
11858
11859 case MSG_DRAW:
11860 d->w = 32;
11861 d->h = 32;
11862
11863 BITMAP *buf = create_bitmap_ex(8,16,16);
11864 BITMAP *bigbmp = create_bitmap_ex(8,d->w,d->h);
11865
11866 if(buf && bigbmp)
11867 {
11868 clear_bitmap(buf);
11869
11870 if(d->bg) //flags only
11871 {
11872 put_flag(buf,0,0,d->d2);
11873 }
11874 else if(d->d1)
11875 {
11876 putcombo(buf,0,0,d->d1,d->fg);
11877
11878 if(Flags&cFLAGS)
11879 put_flags(buf,0,0,d->d1,d->fg,cFLAGS,d->d2);
11880 }
11881
11882 stretch_blit(buf, bigbmp, 0,0, 16, 16, 0, 0, d->w, d->h);
11883 destroy_bitmap(buf);
11884 blit(bigbmp,screen,0,0,d->x-1,d->y-1,d->w,d->h);
11885 destroy_bitmap(bigbmp);
11886 }
11887
11888
11889 /*BITMAP *buf = create_bitmap_ex(8,16,16);
11890 if(buf)
11891 {
11892 clear_bitmap(buf);
11893 if(d->d1)
11894 putcombo(buf,0,0,d->d1,d->fg);
11895
11896 blit(buf,screen,0,0,d->x,d->y,d->w,d->h);
11897 destroy_bitmap(buf);
11898 }*/
11899 break;
11900 }
11901
11902 return D_O_K;
11903 }
11904
11905 /*int32_t d_scombo2_proc(int32_t msg, DIALOG *d, int32_t c)
11906 {
11907 //these are here to bypass compiler warnings about unused arguments
11908 c=c;
11909
11910 switch(msg)
11911 {
11912 case MSG_CLICK:
11913 if (CHECK_CTRL_CMD)
11914 {
11915 select_scombo(d->d1);
11916 }
11917 else
11918 {
11919 select_scombo(d->d1);
11920 }
11921 d_scombo_proc(MSG_DRAW,d,0);
11922 break;
11923
11924
11925 case MSG_DRAW:
11926 BITMAP *buf = create_bitmap_ex(8,16,16);
11927 if(buf)
11928 {
11929 clear_bitmap(buf);
11930 Map.draw_secret2(buf,d->d1);
11931 blit(buf,screen,0,0,d->x,d->y,16,16);
11932 destroy_bitmap(buf);
11933 }
11934 break;
11935 }
11936
11937 return D_O_K;
11938 }*/
11939
11940 int32_t onSecretF();
11941
11942 static int32_t secret_burn_list[] =
11943 {
11944 // dialog control number
11945 4, 5, 6, 7, 48, 49, 50, 51, 92, 93, 94, 95, -1
11946 };
11947
11948 static int32_t secret_arrow_list[] =
11949 {
11950 // dialog control number
11951 8, 9, 10, 52, 53, 54, 96, 97, 98, -1
11952 };
11953
11954 static int32_t secret_bomb_list[] =
11955 {
11956 // dialog control number
11957 11, 12, 55, 56, 99, 100, -1
11958 };
11959
11960 static int32_t secret_boomerang_list[] =
11961 {
11962 // dialog control number
11963 13, 14, 15, 57, 58, 59, 101, 102, 103, -1
11964 };
11965
11966 static int32_t secret_magic_list[] =
11967 {
11968 // dialog control number
11969 16, 17, 60, 61, 104, 105, -1
11970 };
11971
11972 static int32_t secret_sword_list[] =
11973 {
11974 // dialog control number
11975 18, 19, 20, 21, 22, 23, 24, 25, 62, 63, 64, 65, 66, 67, 68, 69, 106, 107, 108, 109, 110, 111, 112, 113, -1
11976 };
11977
11978 static int32_t secret_misc_list[] =
11979 {
11980 // dialog control number
11981 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, -1
11982 };
11983
11984 static TABPANEL secret_tabs[] =
11985 {
11986 // (text)
11987 { (char *)"Burn", D_SELECTED, secret_burn_list, 0, NULL },
11988 { (char *)"Arrow", 0, secret_arrow_list, 0, NULL },
11989 { (char *)"Bomb", 0, secret_bomb_list, 0, NULL },
11990 { (char *)"Boomerang", 0, secret_boomerang_list, 0, NULL },
11991 { (char *)"Magic", 0, secret_magic_list, 0, NULL },
11992 { (char *)"Sword", 0, secret_sword_list, 0, NULL },
11993 { (char *)"Misc", 0, secret_misc_list, 0, NULL },
11994 { NULL, 0, NULL, 0, NULL }
11995 };
11996
11997 static DIALOG secret_dlg[] =
11998 {
11999 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
12000 { jwin_win_proc, 0, 0, 301, 212, vc(14), vc(1), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
12001 { jwin_tab_proc, 6, 25, 289, 156, 0, 0, 0, 0, 0, 0, (void *) secret_tabs, NULL, (void *)secret_dlg },
12002 { jwin_button_proc, 80, 187, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
12003 { jwin_button_proc, 160, 187, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
12004 // 4
12005 { jwin_text_proc, 12, 53, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Any Fire", NULL, NULL },
12006 { jwin_text_proc, 12, 75, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Strong Fire", NULL, NULL },
12007 { jwin_text_proc, 12, 97, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Magic Fire", NULL, NULL },
12008 { jwin_text_proc, 12, 119, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Divine Fire", NULL, NULL },
12009 //8
12010 { jwin_text_proc, 12, 53, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Wooden Arrow", NULL, NULL },
12011 { jwin_text_proc, 12, 75, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Silver Arrow", NULL, NULL },
12012 { jwin_text_proc, 12, 97, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Golden Arrow", NULL, NULL },
12013 //11
12014 { jwin_text_proc, 12, 53, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Bomb", NULL, NULL },
12015 { jwin_text_proc, 12, 75, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Super Bomb", NULL, NULL },
12016 //13
12017 { jwin_text_proc, 12, 53, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Wooden Boomerang", NULL, NULL },
12018 { jwin_text_proc, 12, 75, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Magic Boomerang", NULL, NULL },
12019 { jwin_text_proc, 12, 97, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Fire Boomerang", NULL, NULL },
12020 //16
12021 { jwin_text_proc, 12, 53, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Wand Magic", NULL, NULL },
12022 { jwin_text_proc, 12, 75, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Reflected Magic", NULL, NULL },
12023 //18
12024 { jwin_text_proc, 12, 53, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Sword", NULL, NULL },
12025 { jwin_text_proc, 12, 75, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "White Sword", NULL, NULL },
12026 { jwin_text_proc, 12, 97, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Magic Sword", NULL, NULL },
12027 { jwin_text_proc, 12, 119, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Master Sword", NULL, NULL },
12028 { jwin_text_proc, 160, 53, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Sword Beam", NULL, NULL },
12029 { jwin_text_proc, 160, 75, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "White Sword Beam", NULL, NULL },
12030 { jwin_text_proc, 160, 97, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Magic Sword Beam", NULL, NULL },
12031 { jwin_text_proc, 160, 119, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Master Sword Beam", NULL, NULL },
12032 //26
12033 { jwin_text_proc, 12, 53, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Stairs", NULL, NULL },
12034 { jwin_text_proc, 12, 75, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Reflected Fireball", NULL, NULL },
12035 { jwin_text_proc, 12, 97, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Hookshot", NULL, NULL },
12036 { jwin_text_proc, 12, 119, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Wand", NULL, NULL },
12037 { jwin_text_proc, 12, 141, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Hammer", NULL, NULL },
12038 { jwin_text_proc, 12, 163, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Any Weapon", NULL, NULL },
12039 //32
12040 { jwin_ctext_proc, 235, 53, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Flags 16-31", NULL, NULL },
12041 { jwin_text_proc, 87, 53, 16, 16, vc(11), vc(1), 0, 0, 0, 0, (void *) "Secrets->Next (Flag only)", NULL, NULL },
12042 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, FR_DEEP, 0, (void *) "Secret Combo 03", NULL, NULL },
12043 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, FR_DEEP, 0, (void *) "Secret Combo 04", NULL, NULL },
12044 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, FR_DEEP, 0, (void *) "Secret Combo 05", NULL, NULL },
12045 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, FR_DEEP, 0, (void *) "Secret Combo 06", NULL, NULL },
12046 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, FR_DEEP, 0, (void *) "Secret Combo 07", NULL, NULL },
12047 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, FR_DEEP, 0, (void *) "Secret Combo 08", NULL, NULL },
12048 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, FR_DEEP, 0, (void *) "Secret Combo 09", NULL, NULL },
12049 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, FR_DEEP, 0, (void *) "Secret Combo 10", NULL, NULL },
12050 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, FR_DEEP, 0, (void *) "Secret Combo 11", NULL, NULL },
12051 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, FR_DEEP, 0, (void *) "Secret Combo 12", NULL, NULL },
12052 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, FR_DEEP, 0, (void *) "Secret Combo 13", NULL, NULL },
12053 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, FR_DEEP, 0, (void *) "Secret Combo 14", NULL, NULL },
12054 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, FR_DEEP, 0, (void *) "Secret Combo 15", NULL, NULL },
12055 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, FR_DEEP, 0, (void *) "Secret Combo 16", NULL, NULL },
12056 //48 (burn)
12057 { jwin_frame_proc, 108, 47, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12058 { jwin_frame_proc, 108, 69, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12059 { jwin_frame_proc, 108, 91, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12060 { jwin_frame_proc, 108, 113, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12061 //52 (arrow)
12062 { jwin_frame_proc, 108, 47, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12063 { jwin_frame_proc, 108, 69, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12064 { jwin_frame_proc, 108, 91, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12065 //55 (bomb)
12066 { jwin_frame_proc, 108, 47, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12067 { jwin_frame_proc, 108, 69, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12068 //57 (boomerang)
12069 { jwin_frame_proc, 108, 47, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12070 { jwin_frame_proc, 108, 69, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12071 { jwin_frame_proc, 108, 91, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12072 //60 (magic)
12073 { jwin_frame_proc, 108, 47, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12074 { jwin_frame_proc, 108, 69, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12075 //62 (sword)
12076 { jwin_frame_proc, 108, 47, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12077 { jwin_frame_proc, 108, 69, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12078 { jwin_frame_proc, 108, 91, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12079 { jwin_frame_proc, 108, 113, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12080 { jwin_frame_proc, 256, 47, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12081 { jwin_frame_proc, 256, 69, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12082 { jwin_frame_proc, 256, 91, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12083 { jwin_frame_proc, 256, 113, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12084 //70 (misc)
12085 { jwin_frame_proc, 63, 47, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12086 { jwin_frame_proc, 63, 69, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12087 { jwin_frame_proc, 63, 91, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12088 { jwin_frame_proc, 63, 113, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12089 { jwin_frame_proc, 63, 135, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12090 { jwin_frame_proc, 63, 157, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12091 //76 (16-32)
12092 { jwin_frame_proc, 192, 69, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12093 { jwin_frame_proc, 214, 69, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12094 { jwin_frame_proc, 236, 69, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12095 { jwin_frame_proc, 258, 69, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12096 { jwin_frame_proc, 192, 91, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12097 { jwin_frame_proc, 214, 91, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12098 { jwin_frame_proc, 236, 91, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12099 { jwin_frame_proc, 258, 91, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12100 { jwin_frame_proc, 192, 113, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12101 { jwin_frame_proc, 214, 113, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12102 { jwin_frame_proc, 236, 113, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12103 { jwin_frame_proc, 258, 113, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12104 { jwin_frame_proc, 192, 135, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12105 { jwin_frame_proc, 214, 135, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12106 { jwin_frame_proc, 236, 135, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12107 { jwin_frame_proc, 258, 135, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12108
12109 //92 (burn)
12110 { d_scombo_proc, 110, 49, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12111 { d_scombo_proc, 110, 71, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12112 { d_scombo_proc, 110, 93, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12113 { d_scombo_proc, 110, 115, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12114 //96 (arrow)
12115 { d_scombo_proc, 110, 49, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12116 { d_scombo_proc, 110, 71, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12117 { d_scombo_proc, 110, 93, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12118 //99 (bomb)
12119 { d_scombo_proc, 110, 49, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12120 { d_scombo_proc, 110, 71, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12121 //101 (boomerang)
12122 { d_scombo_proc, 110, 49, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12123 { d_scombo_proc, 110, 71, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12124 { d_scombo_proc, 110, 93, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12125 //104 (magic)
12126 { d_scombo_proc, 110, 49, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12127 { d_scombo_proc, 110, 71, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12128 //106 (sword)
12129 { d_scombo_proc, 110, 49, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12130 { d_scombo_proc, 110, 71, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12131 { d_scombo_proc, 110, 93, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12132 { d_scombo_proc, 110, 115, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12133 { d_scombo_proc, 258, 49, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12134 { d_scombo_proc, 258, 71, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12135 { d_scombo_proc, 258, 93, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12136 { d_scombo_proc, 258, 115, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12137 //114 (misc)
12138 { d_scombo_proc, 65, 49, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12139 { d_scombo_proc, 65, 71, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12140 { d_scombo_proc, 65, 93, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12141 { d_scombo_proc, 65, 115, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12142 { d_scombo_proc, 65, 137, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12143 { d_scombo_proc, 65, 159, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12144 //120 (16-32)
12145 { d_scombo_proc, 194, 71, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12146 { d_scombo_proc, 216, 71, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12147 { d_scombo_proc, 238, 71, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12148 { d_scombo_proc, 260, 71, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12149 { d_scombo_proc, 194, 93, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12150 { d_scombo_proc, 216, 93, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12151 { d_scombo_proc, 238, 93, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12152 { d_scombo_proc, 260, 93, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12153 { d_scombo_proc, 194, 115, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12154 { d_scombo_proc, 216, 115, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12155 { d_scombo_proc, 238, 115, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12156 { d_scombo_proc, 260, 115, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12157 { d_scombo_proc, 194, 137, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12158 { d_scombo_proc, 216, 137, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12159 { d_scombo_proc, 238, 137, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12160 { d_scombo_proc, 260, 137, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12161 //136 Secrets->Next
12162 { jwin_frame_proc, 158, 47, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12163 { d_scombo_proc, 160, 49, 16, 16, 0, 1, 0, 0, 0, 0, NULL, NULL, NULL },
12164 //138
12165 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onHelp, NULL, NULL },
12166 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 'f', 0, 0, 0, (void *) onSecretF, NULL, NULL },
12167 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12168 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
12169 };
12170
12171 int32_t onSecretF()
12172 {
12173 Flags^=cFLAGS;
12174 object_message(secret_dlg+1, MSG_DRAW, 0);
12175 return D_O_K;
12176 }
12177
12178
12179 int32_t onSecretCombo()
12180 {
12181 secret_dlg[0].dp2=get_zc_font(font_lfont);
12182
12183
12184 mapscr *s;
12185
12186 if(CurrentLayer==0)
12187 {
12188 s=Map.CurrScr();
12189 }
12190 else
12191 {
12192 // s=TheMaps[(Map.CurrScr()->layermap[CurrentLayer-1]-1)*MAPSCRS+(Map.CurrScr()->layerscreen[CurrentLayer-1])];
12193 s=Map.AbsoluteScr((Map.CurrScr()->layermap[CurrentLayer-1]-1), (Map.CurrScr()->layerscreen[CurrentLayer-1]));
12194 }
12195 if(!s) return D_O_K;
12196
12197 char secretcombonumstr[27];
12198 sprintf(secretcombonumstr,"Secret Combos for Layer %d", CurrentLayer);
12199 secret_dlg[0].dp = secretcombonumstr;
12200
12201 secret_dlg[92].d1 = s->secretcombo[sBCANDLE];
12202 secret_dlg[92].fg = s->secretcset[sBCANDLE];
12203 secret_dlg[92].d2 = s->secretflag[sBCANDLE];
12204
12205 secret_dlg[93].d1 = s->secretcombo[sRCANDLE];
12206 secret_dlg[93].fg = s->secretcset[sRCANDLE];
12207 secret_dlg[93].d2 = s->secretflag[sRCANDLE];
12208
12209 secret_dlg[94].d1 = s->secretcombo[sWANDFIRE];
12210 secret_dlg[94].fg = s->secretcset[sWANDFIRE];
12211 secret_dlg[94].d2 = s->secretflag[sWANDFIRE];
12212
12213 secret_dlg[95].d1 = s->secretcombo[sDIVINEFIRE];
12214 secret_dlg[95].fg = s->secretcset[sDIVINEFIRE];
12215 secret_dlg[95].d2 = s->secretflag[sDIVINEFIRE];
12216
12217 secret_dlg[96].d1 = s->secretcombo[sARROW];
12218 secret_dlg[96].fg = s->secretcset[sARROW];
12219 secret_dlg[96].d2 = s->secretflag[sARROW];
12220
12221 secret_dlg[97].d1 = s->secretcombo[sSARROW];
12222 secret_dlg[97].fg = s->secretcset[sSARROW];
12223 secret_dlg[97].d2 = s->secretflag[sSARROW];
12224
12225 secret_dlg[98].d1 = s->secretcombo[sGARROW];
12226 secret_dlg[98].fg = s->secretcset[sGARROW];
12227 secret_dlg[98].d2 = s->secretflag[sGARROW];
12228
12229 secret_dlg[99].d1 = s->secretcombo[sBOMB];
12230 secret_dlg[99].fg = s->secretcset[sBOMB];
12231 secret_dlg[99].d2 = s->secretflag[sBOMB];
12232
12233 secret_dlg[100].d1 = s->secretcombo[sSBOMB];
12234 secret_dlg[100].fg = s->secretcset[sSBOMB];
12235 secret_dlg[100].d2 = s->secretflag[sSBOMB];
12236
12237 for(int32_t i=0; i<3; i++)
12238 {
12239 secret_dlg[101+i].d1 = s->secretcombo[sBRANG+i];
12240 secret_dlg[101+i].fg = s->secretcset[sBRANG+i];
12241 secret_dlg[101+i].d2 = s->secretflag[sBRANG+i];
12242 }
12243
12244 for(int32_t i=0; i<2; i++)
12245 {
12246 secret_dlg[104+i].d1 = s->secretcombo[sWANDMAGIC+i];
12247 secret_dlg[104+i].fg = s->secretcset[sWANDMAGIC+i];
12248 secret_dlg[104+i].d2 = s->secretflag[sWANDMAGIC+i];
12249 }
12250
12251 for(int32_t i=0; i<8; i++)
12252 {
12253 secret_dlg[106+i].d1 = s->secretcombo[sSWORD+i];
12254 secret_dlg[106+i].fg = s->secretcset[sSWORD+i];
12255 secret_dlg[106+i].d2 = s->secretflag[sSWORD+i];
12256 }
12257
12258 secret_dlg[114].d1 = s->secretcombo[sSTAIRS];
12259 secret_dlg[114].fg = s->secretcset[sSTAIRS];
12260 secret_dlg[114].d2 = s->secretflag[sSTAIRS];
12261
12262 secret_dlg[115].d1 = s->secretcombo[sREFFIREBALL];
12263 secret_dlg[115].fg = s->secretcset[sREFFIREBALL];
12264 secret_dlg[115].d2 = s->secretflag[sREFFIREBALL];
12265
12266 for(int32_t i=0; i<4; i++)
12267 {
12268 secret_dlg[116+i].d1 = s->secretcombo[sHOOKSHOT+i];
12269 secret_dlg[116+i].fg = s->secretcset[sHOOKSHOT+i];
12270 secret_dlg[116+i].d2 = s->secretflag[sHOOKSHOT+i];
12271 }
12272
12273 for(int32_t i=0; i<16; i++)
12274 {
12275 secret_dlg[120+i].d1 = s->secretcombo[sSECRET01+i];
12276 secret_dlg[120+i].fg = s->secretcset[sSECRET01+i];
12277 secret_dlg[120+i].d2 = s->secretflag[sSECRET01+i];
12278 }
12279
12280 //Sec->Next doesn't have a combo/cset value associated
12281 secret_dlg[137].d1 = 0;
12282 secret_dlg[137].fg = 0;
12283 secret_dlg[137].d2 = s->secretflag[sSECNEXT];
12284
12285 large_dialog(secret_dlg,1.75);
12286
12287 for(int32_t q = 0; secret_dlg[q].proc != NULL; ++q)
12288 {
12289 if(secret_dlg[q].proc == jwin_frame_proc)
12290 secret_dlg[q].w = secret_dlg[q].h = 36;
12291 }
12292
12293 go();
12294
12295 if(do_zqdialog(secret_dlg,3) == 2)
12296 {
12297 saved = false;
12298 s->secretcombo[sBCANDLE] = secret_dlg[92].d1;
12299 s->secretcset[sBCANDLE] = secret_dlg[92].fg;
12300 s->secretflag[sBCANDLE] = secret_dlg[92].d2;
12301
12302 s->secretcombo[sRCANDLE] = secret_dlg[93].d1;
12303 s->secretcset[sRCANDLE] = secret_dlg[93].fg;
12304 s->secretflag[sRCANDLE] = secret_dlg[93].d2;
12305
12306 s->secretcombo[sWANDFIRE] = secret_dlg[94].d1;
12307 s->secretcset[sWANDFIRE] = secret_dlg[94].fg;
12308 s->secretflag[sWANDFIRE] = secret_dlg[94].d2;
12309
12310 s->secretcombo[sDIVINEFIRE] = secret_dlg[95].d1;
12311 s->secretcset[sDIVINEFIRE] = secret_dlg[95].fg;
12312 s->secretflag[sDIVINEFIRE] = secret_dlg[95].d2;
12313
12314 s->secretcombo[sARROW] = secret_dlg[96].d1;
12315 s->secretcset[sARROW] = secret_dlg[96].fg;
12316 s->secretflag[sARROW] = secret_dlg[96].d2;
12317
12318 s->secretcombo[sSARROW] = secret_dlg[97].d1;
12319 s->secretcset[sSARROW] = secret_dlg[97].fg;
12320 s->secretflag[sSARROW] = secret_dlg[97].d2;
12321
12322 s->secretcombo[sGARROW] = secret_dlg[98].d1;
12323 s->secretcset[sGARROW] = secret_dlg[98].fg;
12324 s->secretflag[sGARROW] = secret_dlg[98].d2;
12325
12326 s->secretcombo[sBOMB] = secret_dlg[99].d1;
12327 s->secretcset[sBOMB] = secret_dlg[99].fg;
12328 s->secretflag[sBOMB] = secret_dlg[99].d2;
12329
12330 s->secretcombo[sSBOMB] = secret_dlg[100].d1;
12331 s->secretcset[sSBOMB] = secret_dlg[100].fg;
12332 s->secretflag[sSBOMB] = secret_dlg[100].d2;
12333
12334 for(int32_t i=0; i<3; i++)
12335 {
12336 s->secretcombo[sBRANG+i] = secret_dlg[101+i].d1;
12337 s->secretcset[sBRANG+i] = secret_dlg[101+i].fg;
12338 s->secretflag[sBRANG+i] = secret_dlg[101+i].d2;
12339 }
12340
12341 for(int32_t i=0; i<2; i++)
12342 {
12343 s->secretcombo[sWANDMAGIC+i] = secret_dlg[104+i].d1;
12344 s->secretcset[sWANDMAGIC+i] = secret_dlg[104+i].fg;
12345 s->secretflag[sWANDMAGIC+i] = secret_dlg[104+i].d2;
12346 }
12347
12348 for(int32_t i=0; i<8; i++)
12349 {
12350 s->secretcombo[sSWORD+i] = secret_dlg[106+i].d1;
12351 s->secretcset[sSWORD+i] = secret_dlg[106+i].fg;
12352 s->secretflag[sSWORD+i] = secret_dlg[106+i].d2;
12353 }
12354
12355 s->secretcombo[sSTAIRS] = secret_dlg[114].d1;
12356 s->secretcset[sSTAIRS] = secret_dlg[114].fg;
12357 s->secretflag[sSTAIRS] = secret_dlg[114].d2;
12358
12359 s->secretcombo[sREFFIREBALL] = secret_dlg[115].d1;
12360 s->secretcset[sREFFIREBALL] = secret_dlg[115].fg;
12361 s->secretflag[sREFFIREBALL] = secret_dlg[115].d2;
12362
12363 for(int32_t i=0; i<4; i++)
12364 {
12365 s->secretcombo[sHOOKSHOT+i] = secret_dlg[116+i].d1;
12366 s->secretcset[sHOOKSHOT+i] = secret_dlg[116+i].fg;
12367 s->secretflag[sHOOKSHOT+i] = secret_dlg[116+i].d2;
12368 }
12369
12370 for(int32_t i=0; i<16; i++)
12371 {
12372 s->secretcombo[sSECRET01+i] = secret_dlg[120+i].d1;
12373 s->secretcset[sSECRET01+i] = secret_dlg[120+i].fg;
12374 s->secretflag[sSECRET01+i] = secret_dlg[120+i].d2;
12375 }
12376 s->secretflag[sSECNEXT] = secret_dlg[137].d2;
12377
12378 }
12379
12380 comeback();
12381 return D_O_K;
12382 }
12383
12384 static DIALOG under_dlg[] =
12385 {
12386 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
12387 { jwin_win_proc, 72, 60, 176+1,120+1,vc(14), vc(1), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
12388 { jwin_text_proc, 115, 83, 20, 20, vc(14), vc(1), 0, 0, 0, 0, (void *) "Current", NULL, NULL },
12389 { d_comboframe_proc, 122, 92, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12390 { d_combo_proc, 124, 94, 16, 16, 0, 0, 0, D_NOCLICK, 0, 0, NULL, NULL, NULL },
12391 { jwin_text_proc, 184, 83, 20, 20, vc(14), vc(1), 0, 0, 0, 0, (void *) "New", NULL, NULL },
12392 { d_comboframe_proc, 182, 92, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
12393 { d_combo_proc, 184, 94, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12394 { jwin_button_proc, 90, 124, 61, 21, vc(14), vc(1), 's', D_EXIT, 0, 0, (void *) "&Set", NULL, NULL },
12395 { jwin_button_proc, 170, 124, 61, 21, vc(14), vc(1), 'c', D_EXIT, 0, 0, (void *) "&Cancel", NULL, NULL },
12396 { jwin_button_proc, 90, 152, 61, 21, vc(14), vc(1), 'a', D_EXIT, 0, 0, (void *) "Set &All", NULL, NULL },
12397 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onHelp, NULL, NULL },
12398 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12399 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
12400 };
12401
12402 int32_t onUnderCombo()
12403 {
12404 char titlebuf[64];
12405 sprintf(titlebuf, "Under Combo (Layer %d)", CurrentLayer);
12406 under_dlg[0].dp = titlebuf;
12407 under_dlg[0].dp2 = get_zc_font(font_lfont);
12408 mapscr* scr;
12409 if(CurrentLayer==0)
12410 {
12411 scr=Map.CurrScr();
12412 }
12413 else
12414 {
12415 auto map=Map.CurrScr()->layermap[CurrentLayer-1]-1;
12416 auto screen=Map.CurrScr()->layerscreen[CurrentLayer-1];
12417 scr = Map.AbsoluteScr(map,screen);
12418 }
12419 if(!scr) return D_O_K;
12420
12421 under_dlg[3].d1=scr->undercombo;
12422 under_dlg[3].fg=scr->undercset;
12423
12424 under_dlg[6].d1=Combo;
12425 under_dlg[6].fg=CSet;
12426
12427 large_dialog(under_dlg);
12428 // Doesn't place "New" and "Current" text too well
12429 under_dlg[1].x=342;
12430 under_dlg[4].x=438;
12431
12432 int32_t ret = do_zqdialog(under_dlg,-1);
12433
12434 if(ret==7)
12435 {
12436 saved=false;
12437 scr->undercombo = under_dlg[6].d1;
12438 scr->undercset = under_dlg[6].fg;
12439 }
12440
12441 if(ret==9 && jwin_alert("Confirm Overwrite","Set all Under Combos","on this map?",NULL,"&Yes","&No",'y','n',get_zc_font(font_lfont))==1)
12442 {
12443 saved=false;
12444
12445 for(int32_t i=0; i<128; i++)
12446 {
12447 Map.Scr(i)->undercombo = under_dlg[6].d1;
12448 Map.Scr(i)->undercset = under_dlg[6].fg;
12449 }
12450 }
12451
12452 return D_O_K;
12453 }
12454
12455 static DIALOG list_dlg[] =
12456 {
12457 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
12458 12 { jwin_win_proc, 60-12, 40, 200+24, 148, vc(14), vc(1), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
12459 12 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
12460 12 { jwin_list_proc, 72-12-4, 60+4, 176+24+8, 92+3, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, D_EXIT, 0, 0, NULL, NULL, NULL },
12461 12 { jwin_button_proc, 90, 163, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
12462 12 { jwin_button_proc, 170, 163, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
12463 12 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
12464 };
12465
12466 /*
12467 typedef struct item_struct {
12468 char *s;
12469 int32_t i;
12470 } item_struct;
12471 */
12472 item_struct bii[MAXITEMS+1];
12473 int32_t bii_cnt=-1;
12474
12475 void build_bii_list(bool usenone)
12476 {
12477 int32_t start=bii_cnt=0;
12478
12479 if(usenone)
12480 {
12481 bii[0].s = (char *)"(None)";
12482 bii[0].i = -2;
12483 bii_cnt=start=1;
12484 }
12485
12486 for(int32_t i=0; i<MAXITEMS; i++)
12487 {
12488 bii[bii_cnt].s = item_string[i];
12489 bii[bii_cnt].i = i;
12490 ++bii_cnt;
12491 }
12492
12493 for(int32_t i=start; i<bii_cnt-1; i++)
12494 {
12495 for(int32_t j=i+1; j<bii_cnt; j++)
12496 {
12497 if(stricmp(bii[i].s,bii[j].s)>0 && strcmp(bii[j].s,""))
12498 {
12499 zc_swap(bii[i],bii[j]);
12500 }
12501 }
12502 }
12503 }
12504
12505
12506 const char *itemlist(int32_t index, int32_t *list_size)
12507 {
12508 if(index<0)
12509 {
12510 *list_size = bii_cnt;
12511 return NULL;
12512 }
12513
12514 return bii[index].s;
12515 }
12516 const char *itemlist_num(int32_t index, int32_t *list_size)
12517 {
12518 if(index<0)
12519 {
12520 *list_size = bii_cnt;
12521 return NULL;
12522 }
12523 static char biin_buf[64+6];
12524 if(bii[index].i < 0)
12525 return bii[index].s;
12526 sprintf(biin_buf, "%s (%03d)", bii[index].s, bii[index].i);
12527 return biin_buf;
12528 }
12529
12530 // disable items on dmaps stuff
12531 int32_t DI[MAXITEMS];
12532 int32_t nDI;
12533
12534 void initDI(int32_t index)
12535 {
12536 int32_t j=0;
12537
12538 for(int32_t i=0; i<MAXITEMS; i++)
12539 {
12540 int32_t index1=bii[i].i; // true index of item in dmap's DI list
12541
12542 if(DMaps[index].disableditems[index1])
12543 {
12544 DI[j]=i;
12545 j++;
12546 }
12547 }
12548
12549 nDI=j;
12550
12551 for(int32_t i=j; i<MAXITEMS; i++) DI[j]=0;
12552
12553 return;
12554 }
12555
12556 void insertDI(int32_t id, int32_t index)
12557 {
12558 int32_t trueid=bii[id].i;
12559 DMaps[index].disableditems[trueid] |= 1; //bit set
12560 initDI(index);
12561 return;
12562 }
12563
12564 void deleteDI(int32_t id, int32_t index)
12565 {
12566 int32_t i=DI[id];
12567 int32_t trueid=bii[i].i;
12568 DMaps[index].disableditems[trueid] &= (~1); // bit clear
12569 initDI(index);
12570 return;
12571 }
12572
12573 const char *DIlist(int32_t index, int32_t *list_size)
12574 {
12575 if(index<0)
12576 {
12577 *list_size = nDI;
12578 return NULL;
12579 }
12580
12581 int32_t i=DI[index];
12582 return bii[i].s;
12583
12584 }
12585
12586 weapon_struct biw[MAXWPNS];
12587 int32_t biw_cnt=-1;
12588
12589 void build_biw_list()
12590 {
12591 int32_t start=biw_cnt=0;
12592
12593 for(int32_t i=start; i<MAXWPNS; i++)
12594 {
12595 biw[biw_cnt].s = (char *)weapon_string[i];
12596 biw[biw_cnt].i = i;
12597 ++biw_cnt;
12598 }
12599
12600 for(int32_t i=start; i<biw_cnt-1; i++)
12601 {
12602 for(int32_t j=i+1; j<biw_cnt; j++)
12603 if(stricmp(biw[i].s,biw[j].s)>0 && strcmp(biw[j].s,""))
12604 zc_swap(biw[i],biw[j]);
12605 }
12606 }
12607
12608 const char *weaponlist(int32_t index, int32_t *list_size)
12609 {
12610 if(index<0)
12611 {
12612 *list_size = biw_cnt;
12613 return NULL;
12614 }
12615
12616 return biw[index].s;
12617 }
12618 const char *weaponlist_num(int32_t index, int32_t *list_size)
12619 {
12620 if(index<0)
12621 {
12622 *list_size = biw_cnt;
12623 return NULL;
12624 }
12625 static char biwn_buf[64+6];
12626 if(biw[index].i < 0)
12627 return biw[index].s;
12628 sprintf(biwn_buf, "%s (%03d)", biw[index].s, biw[index].i);
12629 return biwn_buf;
12630 }
12631 int32_t writeoneweapon(PACKFILE *f, int32_t index)
12632 {
12633 dword section_version=V_WEAPONS;
12634 int32_t zversion = ZELDA_VERSION;
12635 int32_t zbuild = VERSION_BUILD;
12636 int32_t iid = biw[index].i;
12637 al_trace("Writing Weapon Sprite .zwpnspr file for weapon id: %d\n", iid);
12638
12639 //section version info
12640 if(!p_iputl(zversion,f))
12641 {
12642 return 0;
12643 }
12644 if(!p_iputl(zbuild,f))
12645 {
12646 return 0;
12647 }
12648 if(!p_iputw(section_version,f))
12649 {
12650 return 0;
12651 }
12652
12653 if(!write_deprecated_section_cversion(section_version, f))
12654 {
12655 return 0;
12656 }
12657
12658 //weapon string
12659
12660 if(!pfwrite((char *)weapon_string[iid], 64, f))
12661 {
12662 return 0;
12663 }
12664
12665 if(!p_putc(wpnsbuf[iid].misc,f))
12666 {
12667 return 0;
12668 }
12669
12670 if(!p_putc(wpnsbuf[iid].csets,f))
12671 {
12672 return 0;
12673 }
12674
12675 if(!p_putc(wpnsbuf[iid].frames,f))
12676 {
12677 return 0;
12678 }
12679
12680 if(!p_putc(wpnsbuf[iid].speed,f))
12681 {
12682 return 0;
12683 }
12684
12685 if(!p_putc(wpnsbuf[iid].type,f))
12686 {
12687 return 0;
12688 }
12689
12690 if(!p_iputw(wpnsbuf[iid].script,f))
12691 {
12692 return 0;
12693 }
12694
12695 //2.55 starts here
12696 if(!p_iputl(wpnsbuf[iid].tile,f))
12697 {
12698 return 0;
12699 }
12700
12701 return 1;
12702 }
12703
12704
12705 int32_t readoneweapon(PACKFILE *f, int32_t index)
12706 {
12707 dword section_version = 0;
12708 int32_t zversion = 0;
12709 int32_t zbuild = 0;
12710 wpndata tempwpnspr;
12711 memset(&tempwpnspr, 0, sizeof(wpndata));
12712
12713
12714 //char dmapstring[64]={0};
12715 //section version info
12716 if(!p_igetl(&zversion,f))
12717 {
12718 return 0;
12719 }
12720 if(!p_igetl(&zbuild,f))
12721 {
12722 return 0;
12723 }
12724 if(!p_igetw(&section_version,f))
12725 {
12726 return 0;
12727 }
12728 if(!read_deprecated_section_cversion(f))
12729 {
12730 return 0;
12731 }
12732 al_trace("readoneweapon section_version: %d\n", section_version);
12733
12734 if ( zversion > ZELDA_VERSION )
12735 {
12736 al_trace("Cannot read .zwpnspr packfile made in ZC version (%x) in this version of ZC (%x)\n", zversion, ZELDA_VERSION);
12737 return 0;
12738 }
12739
12740 else if ( ( section_version > V_WEAPONS ) )
12741 {
12742 al_trace("Cannot read .zwpnspr packfile made using V_WEAPONS (%d)\n", section_version);
12743 return 0;
12744
12745 }
12746 else
12747 {
12748 al_trace("Reading a .zwpnspr packfile made in ZC Version: %x, Build: %d\n", zversion, zbuild);
12749 }
12750
12751 char tmp_wpn_name[64];
12752 memset(tmp_wpn_name,0,64);
12753 if(!pfread(&tmp_wpn_name, 64, f))
12754 {
12755 return 0;
12756 }
12757
12758 word oldtile = 0;
12759 if(section_version < 8)
12760 if(!p_igetw(&oldtile,f))
12761 return 0;
12762
12763 if(!p_getc(&tempwpnspr.misc,f))
12764 {
12765 return 0;
12766 }
12767
12768 if(!p_getc(&tempwpnspr.csets,f))
12769 {
12770 return 0;
12771 }
12772
12773 if(!p_getc(&tempwpnspr.frames,f))
12774 {
12775 return 0;
12776 }
12777
12778 if(!p_getc(&tempwpnspr.speed,f))
12779 {
12780 return 0;
12781 }
12782
12783 if(!p_getc(&tempwpnspr.type,f))
12784 {
12785 return 0;
12786 }
12787
12788 if(!p_igetw(&tempwpnspr.script,f))
12789 {
12790 return 0;
12791 }
12792
12793 //2.55 starts here
12794 if ( zversion >= 0x255 )
12795 {
12796 if ( section_version >= 7 )
12797 {
12798 if(!p_igetl(&tempwpnspr.tile,f))
12799 {
12800 return 0;
12801 }
12802 }
12803 }
12804 if ( zversion < 0x255 )
12805 {
12806 tempwpnspr.tile = oldtile;
12807 }
12808 ::memcpy( &(wpnsbuf[biw[index].i]),&tempwpnspr, sizeof(wpndata));
12809 ::memcpy(weapon_string[biw[index].i], tmp_wpn_name, 64);
12810
12811 return 1;
12812 }
12813
12814 static int32_t seldata_copy;
12815 static void (*seldata_paste_func)(int32_t, int32_t);
12816
12817 void seldata_rclick_func(int32_t index, int32_t x, int32_t y)
12818 {
12819 NewMenu rcmenu {
12820 { "&Copy", [&](){seldata_copy = index;} },
12821 { "Paste", "&v", [&]()
12822 {
12823 seldata_paste_func(seldata_copy, index);
12824 saved = false;
12825 }, 0, seldata_copy < 0 },
12826 };
12827 rcmenu.pop(x, y);
12828 }
12829
12830 int32_t select_data(const char *prompt,int32_t index,const char *(proc)(int32_t,int32_t*), FONT *title_font, void (*copyFunc)(int32_t, int32_t))
12831 {
12832 if(proc==NULL)
12833 return -1;
12834
12835 list_dlg[0].dp=(void *)prompt;
12836 list_dlg[0].dp2=title_font;
12837 list_dlg[2].d1=index;
12838 ListData select_list(proc, &font);
12839 list_dlg[2].dp=(void *) &select_list;
12840
12841 large_dialog(list_dlg);
12842
12843 seldata_copy=-1;
12844 seldata_paste_func=copyFunc;
12845 if(copyFunc)
12846 {
12847 list_dlg[2].flags|=D_USER<<1;
12848 list_dlg[2].dp3=(void*)seldata_rclick_func;
12849 }
12850 else
12851 {
12852 list_dlg[2].flags&=~(D_USER<<1);
12853 list_dlg[2].dp3=0;
12854 }
12855
12856 int32_t ret=do_zqdialog(list_dlg,2);
12857
12858 if(ret==0||ret==4)
12859 {
12860 position_mouse_z(0);
12861 return -1;
12862 }
12863
12864 return list_dlg[2].d1;
12865 }
12866
12867 int32_t select_data(const char *prompt,int32_t index,const char *(proc)(int32_t,int32_t*), const char *b1, const char *b2, FONT *title_font, void (*copyFunc)(int32_t, int32_t))
12868 {
12869 if(proc==NULL)
12870 return -1;
12871
12872 list_dlg[0].dp=(void *)prompt;
12873 list_dlg[0].dp2=title_font;
12874 list_dlg[2].d1=index;
12875 ListData select_data_list(proc, &font);
12876 list_dlg[2].dp=(void *) &select_data_list;
12877 list_dlg[3].dp=(void *)b1;
12878 list_dlg[4].dp=(void *)b2;
12879
12880 large_dialog(list_dlg);
12881
12882 seldata_copy=-1;
12883 seldata_paste_func=copyFunc;
12884 if(copyFunc)
12885 {
12886 list_dlg[2].flags|=D_USER<<1;
12887 list_dlg[2].dp3=(void*)seldata_rclick_func;
12888 }
12889 else
12890 {
12891 list_dlg[2].flags&=~(D_USER<<1);
12892 list_dlg[2].dp3=0;
12893 }
12894
12895 int32_t ret = do_zqdialog(list_dlg,2);
12896 list_dlg[3].dp=(void *) "OK";
12897 list_dlg[4].dp=(void *) "Cancel";
12898
12899 if(ret==0||ret==4)
12900 {
12901 position_mouse_z(0);
12902 return -1;
12903 }
12904
12905 position_mouse_z(0);
12906 return list_dlg[2].d1;
12907 }
12908
12909 static char sfx_str_buf[42];
12910
12911 const char *sfxlist(int32_t index, int32_t *list_size)
12912 {
12913 if(index>=0)
12914 {
12915 bound(index,0,WAV_COUNT-1);
12916 sprintf(sfx_str_buf,"%d: %s",index, index ? sfx_string[index] : "(None)");
12917 return sfx_str_buf;
12918 }
12919
12920 *list_size=WAV_COUNT;
12921 return NULL;
12922 }
12923
12924 12 static ListData sfx_list(sfxlist, &font);
12925
12926 const char *screenscriptdroplist(int32_t index, int32_t *list_size)
12927 {
12928 if(index<0)
12929 {
12930 *list_size = biscreens_cnt;
12931 return NULL;
12932 }
12933
12934 return biscreens[index].first.c_str();
12935 }
12936
12937 //droplist like the dialog proc, naming scheme for this stuff is awful...
12938 12 static ListData screenscript_list(screenscriptdroplist, &a4fonts[font_pfont]);
12939
12940 int32_t onScreenScript()
12941 {
12942 call_screendata_dialog(7);
12943 return D_O_K;
12944 }
12945
12946 int32_t onScrData()
12947 {
12948 restore_mouse();
12949 call_screendata_dialog();
12950 return D_O_K;
12951 }
12952
12953 const char *roomslist(int32_t index, int32_t *list_size)
12954 {
12955 if(index>=0)
12956 {
12957 if(index>=MAXROOMTYPES)
12958 index=MAXROOMTYPES-1;
12959
12960 return roomtype_string[index];
12961 }
12962
12963 *list_size=MAXROOMTYPES;
12964 return NULL;
12965 }
12966
12967 static char number_str_buf[MIDI_TRACK_BUFFER_SIZE];
12968 int32_t number_list_size=1;
12969 bool number_list_zero=false;
12970
12971 const char *numberlist(int32_t index, int32_t *list_size)
12972 {
12973 if(index>=0)
12974 {
12975 bound(index,0,number_list_size-1);
12976 sprintf(number_str_buf,"%d",index+(number_list_zero?0:1));
12977 return number_str_buf;
12978 }
12979
12980 *list_size=number_list_size;
12981 return NULL;
12982 }
12983
12984 static char dmap_str_buf[37];
12985 int32_t dmap_list_size=MAXDMAPS;
12986 bool dmap_list_zero=true;
12987
12988 const char *dmaplist(int32_t index, int32_t *list_size)
12989 {
12990 if(index>=0)
12991 {
12992 bound(index,0,dmap_list_size-1);
12993 sprintf(dmap_str_buf,"%3d-%s",index+(dmap_list_zero?0:1), DMaps[index].name);
12994 return dmap_str_buf;
12995 }
12996
12997 *list_size=dmap_list_size;
12998 return NULL;
12999 }
13000
13001 char *hexnumlist(int32_t index, int32_t *list_size)
13002 {
13003 if(index>=0)
13004 {
13005 bound(index,0,number_list_size-1);
13006 sprintf(number_str_buf,"%X",index+(number_list_zero?0:1));
13007 return number_str_buf;
13008 }
13009
13010 *list_size=number_list_size;
13011 return NULL;
13012 }
13013
13014 const char *maplist(int32_t index, int32_t *list_size)
13015 {
13016 if(index>=0)
13017 {
13018 bound(index,0,MAXMAPS-1);
13019 sprintf(number_str_buf,"%d",index+1);
13020 return number_str_buf;
13021 }
13022
13023 *list_size=MAXMAPS;
13024 return NULL;
13025 }
13026
13027 const char *gotomaplist(int32_t index, int32_t *list_size)
13028 {
13029 if(index>=0)
13030 {
13031 bound(index,0,map_count-1);
13032 sprintf(number_str_buf,"%d",index+1);
13033 return number_str_buf;
13034 }
13035
13036 *list_size = map_count;
13037 return NULL;
13038 }
13039
13040 const char *midilist(int32_t index, int32_t *list_size)
13041 {
13042 if(index>=0)
13043
13044 {
13045 bound(index,0,MAXCUSTOMMIDIS_ZQ-1);
13046 return midi_string[index];
13047 }
13048
13049 *list_size=MAXCUSTOMMIDIS_ZQ;
13050 return NULL;
13051 }
13052
13053 const char *custommidilist(int32_t index, int32_t *list_size)
13054 {
13055 if(index>=0)
13056 {
13057 bound(index,0,MAXCUSTOMMIDIS_ZQ-1);
13058 sprintf(number_str_buf,"%3d - %s",index+(number_list_zero?0:1),customtunes[index].data?customtunes[index].title:"(Empty)");
13059 return number_str_buf;
13060 }
13061
13062 *list_size=number_list_size;
13063 return NULL;
13064 }
13065
13066 const char *enhancedmusiclist(int32_t index, int32_t *list_size)
13067 {
13068 index=index; //this is here to prevent unused parameter warnings
13069 list_size=list_size; //this is here to prevent unused parameter warnings
13070 /*if(index>=0)
13071 {
13072 bound(index,0,MAXMUSIC-1);
13073 sprintf(number_str_buf,"%3d - %s",index+(number_list_zero?0:1),enhancedMusic[index].filename[0]?enhancedMusic[index].title:"(Empty)" );
13074 return number_str_buf;
13075 }
13076 *list_size=number_list_size;*/
13077 return NULL;
13078 }
13079
13080
13081 const char *levelnumlist(int32_t index, int32_t *list_size)
13082 {
13083 if(index>=0)
13084 {
13085 bound(index,0,0xFFF);
13086 sprintf(number_str_buf,"%.3X - %s",index,palnames[index]);
13087 return number_str_buf;
13088 }
13089
13090 *list_size=MAXLEVELS;
13091 return NULL;
13092 }
13093
13094 static char shop_str_buf[40];
13095 int32_t shop_list_size=1;
13096
13097 const char *shoplist(int32_t index, int32_t *list_size)
13098 {
13099 if(index>=0)
13100 {
13101 bound(index,0,shop_list_size-1);
13102 sprintf(shop_str_buf,"%3d: %s",index,QMisc.shop[index].name);
13103 return shop_str_buf;
13104 }
13105
13106 *list_size=shop_list_size;
13107 return NULL;
13108 }
13109
13110 static char bottle_str_buf[40];
13111 int32_t bottle_list_size=1;
13112
13113 const char *bottlelist(int32_t index, int32_t *list_size)
13114 {
13115 if(index>=0)
13116 {
13117 bound(index,0,bottle_list_size-1);
13118 sprintf(bottle_str_buf,"%2d: %s",index+1,QMisc.bottle_types[index].name);
13119 return bottle_str_buf;
13120 }
13121
13122 *list_size=bottle_list_size;
13123 return NULL;
13124 }
13125
13126 static char bottleshop_str_buf[40];
13127 int32_t bottleshop_list_size=1;
13128
13129 const char *bottleshoplist(int32_t index, int32_t *list_size)
13130 {
13131 if(index>=0)
13132 {
13133 bound(index,0,bottleshop_list_size-1);
13134 sprintf(bottleshop_str_buf,"%3d: %s",index,QMisc.bottle_shop_types[index].name);
13135 return bottleshop_str_buf;
13136 }
13137
13138 *list_size=bottleshop_list_size;
13139 return NULL;
13140 }
13141
13142 static char info_str_buf[40];
13143 int32_t info_list_size=1;
13144
13145 const char *infolist(int32_t index, int32_t *list_size)
13146 {
13147 if(index>=0)
13148 {
13149 bound(index,0,info_list_size-1);
13150 sprintf(info_str_buf,"%3d: %s",index,QMisc.info[index].name);
13151 return info_str_buf;
13152 }
13153
13154 *list_size=info_list_size;
13155 return NULL;
13156 }
13157
13158 bool mapcount_will_affect_layers(word newmapcount)
13159 {
13160 for(int32_t i=0; i<(newmapcount)*MAPSCRS; i++)
13161 {
13162 mapscr *layerchecker=&TheMaps[i];
13163
13164 for(int32_t j=0; j<6; j++)
13165 {
13166 if(layerchecker->layermap[j]>(newmapcount))
13167 {
13168 return true;
13169 }
13170 }
13171 }
13172 return false;
13173 }
13174
13175 void update_map_count(word newmapcount)
13176 {
13177 if(map_count == newmapcount) return;
13178 saved = false;
13179 setMapCount2(newmapcount);
13180 //Prevent the nine 'last mapscreen' buttons from pointing to invlid locations
13181 //if the user reduces the mapcount. -Z ( 23rd September, 2019 )
13182 for ( int32_t q = 0; q < 9; q++ )
13183 {
13184 map_page[q].map = ( map_page[q].map > newmapcount-1 ) ? newmapcount-1 : map_page[q].map;
13185 }
13186 for(int32_t i=0; i<(newmapcount)*MAPSCRS; i++)
13187 {
13188 fix_layers(&TheMaps[i], false);
13189 }
13190
13191 refresh(rMAP+rSCRMAP+rMENU);
13192 }
13193
13194 int32_t onGotoMap()
13195 {
13196 int32_t ret = select_data("Goto Map",Map.getCurrMap(),gotomaplist,get_zc_font(font_lfont));
13197
13198 if(ret >= 0)
13199 {
13200 int32_t m=Map.getCurrMap();
13201 Map.setCurrMap(ret);
13202 }
13203
13204 refresh(rALL);
13205 return D_O_K;
13206 }
13207
13208 int32_t onFlags()
13209 {
13210 restore_mouse();
13211 int32_t ret=select_cflag("Select Combo Flag",Flag);
13212 position_mouse_z(0);
13213
13214 if(ret>=0)
13215 {
13216 Flag=ret;
13217 refresh(rMENU);
13218 doflags();
13219 }
13220
13221 return D_O_K;
13222 }
13223
13224 static DIALOG usedcombo_list_dlg[] =
13225 {
13226 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
13227 12 { jwin_win_proc, 60-12, 40, 200+24, 148, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Combos Used", NULL, NULL },
13228 12 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
13229 12 { jwin_textbox_proc, 72-12, 60+4, 176+24+1, 92+4, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, D_EXIT, 0, 0, NULL, NULL, NULL },
13230 12 { jwin_button_proc, 130, 163, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
13231 12 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
13232 };
13233
13234
13235
13236 int32_t onUsedCombos()
13237 {
13238 restore_mouse();
13239 usedcombo_list_dlg[0].dp2=get_zc_font(font_lfont);
13240
13241 int32_t usedcombos[7][300][2];
13242 char combolist_text[65536];
13243 char temptext[80];
13244
13245 int32_t drawmap=Map.getCurrMap();
13246 int32_t drawscr=Map.getCurrScr();
13247 int32_t counter[7];
13248
13249 for(int32_t layer=0; layer<7; ++layer)
13250 {
13251 counter[layer]=0;
13252
13253 if(layer==0)
13254 {
13255 drawmap=Map.getCurrMap();
13256 drawscr=Map.getCurrScr();
13257 }
13258 else
13259 {
13260 drawmap=Map.CurrScr()->layermap[layer-1]-1;
13261 drawscr=Map.CurrScr()->layerscreen[layer-1];
13262 }
13263 mapscr* draw_mapscr = Map.AbsoluteScr(drawmap, drawscr);
13264 if(!draw_mapscr) continue;
13265
13266 usedcombos[layer][0][0]=draw_mapscr->data[0];
13267 usedcombos[layer][0][1]=1;
13268 counter[layer]=1;
13269
13270 for(int32_t i=1; i<176; ++i)
13271 {
13272 bool used=false;
13273
13274 for(int32_t j=0; j<counter[layer]; ++j)
13275 {
13276 if(usedcombos[layer][j][0]==draw_mapscr->data[i])
13277 {
13278 ++usedcombos[layer][j][1];
13279 used=true;
13280 break;
13281 }
13282 }
13283
13284 if(!used)
13285 {
13286 usedcombos[layer][counter[layer]][0]=draw_mapscr->data[i];
13287 usedcombos[layer][counter[layer]][1]=1;
13288 ++counter[layer];
13289 }
13290 }
13291
13292 for(int32_t i=0; i<counter[layer]-1; i++)
13293 {
13294 for(int32_t j=i+1; j<counter[layer]; j++)
13295 {
13296 if(usedcombos[layer][i][0]>usedcombos[layer][j][0])
13297 {
13298 zc_swap(usedcombos[layer][i][0],usedcombos[layer][j][0]);
13299 zc_swap(usedcombos[layer][i][1],usedcombos[layer][j][1]);
13300 }
13301 }
13302 }
13303 }
13304
13305 sprintf(combolist_text, " ");
13306
13307 for(int32_t layer=0; layer<7; ++layer)
13308 {
13309 if(counter[layer]>0)
13310 {
13311 if(layer>0)
13312 {
13313 strcat(combolist_text, "\n");
13314 }
13315
13316 sprintf(temptext, "Combos on layer %d\n-----------------\n", layer);
13317 strcat(combolist_text, temptext);
13318
13319 for(int32_t i=0; i<counter[layer]; i++)
13320 {
13321 if((i<counter[layer]-1) && (((usedcombos[layer][i][1]==usedcombos[layer][i+1][1]&&(usedcombos[layer][i][0]+1==usedcombos[layer][i+1][0])) && ((i==0) || ((usedcombos[layer][i][1]!=usedcombos[layer][i-1][1])||((usedcombos[layer][i][0]-1!=usedcombos[layer][i-1][0])))))))
13322 {
13323 sprintf(temptext, "%5d ", usedcombos[layer][i][0]);
13324 strcat(combolist_text, temptext);
13325 }
13326 else if(((i>0) && (((usedcombos[layer][i][1]==usedcombos[layer][i-1][1])&&((usedcombos[layer][i][0]-1==usedcombos[layer][i-1][0]))) && ((i==counter[layer]-1) || ((usedcombos[layer][i][1]!=usedcombos[layer][i+1][1])||((usedcombos[layer][i][0]+1!=usedcombos[layer][i+1][0])))))))
13327 {
13328 sprintf(temptext, "- %5d (%3d)\n", usedcombos[layer][i][0],usedcombos[layer][i][1]);
13329 strcat(combolist_text, temptext);
13330 }
13331 else if(((i==0) && ((usedcombos[layer][i][1]!=usedcombos[layer][i+1][1])||((usedcombos[layer][i][0]+1!=usedcombos[layer][i+1][0]))))||
13332 ((i==counter[layer]-1) && ((usedcombos[layer][i][1]!=usedcombos[layer][i-1][1])||((usedcombos[layer][i][0]-1!=usedcombos[layer][i-1][0]))))||
13333 ((i>0) && (i<counter[layer]-1) && ((usedcombos[layer][i][1]!=usedcombos[layer][i+1][1])||((usedcombos[layer][i][0]+1!=usedcombos[layer][i+1][0]))) && ((usedcombos[layer][i][1]!=usedcombos[layer][i-1][1])||((usedcombos[layer][i][0]-1!=usedcombos[layer][i-1][0])))))
13334 {
13335 sprintf(temptext, " %5d (%3d)\n", usedcombos[layer][i][0],usedcombos[layer][i][1]);
13336 strcat(combolist_text, temptext);
13337 }
13338 }
13339 }
13340 }
13341
13342 strcat(combolist_text, "\n");
13343 usedcombo_list_dlg[2].dp=combolist_text;
13344 usedcombo_list_dlg[2].d2=0;
13345
13346 large_dialog(usedcombo_list_dlg);
13347
13348 do_zqdialog(usedcombo_list_dlg,2);
13349 position_mouse_z(0);
13350 return D_O_K;
13351 }
13352
13353 int32_t onItem()
13354 {
13355 restore_mouse();
13356 int32_t exit_status;
13357 int32_t current_item=Map.CurrScr()->hasitem != 0 ? Map.CurrScr()->item : -1;
13358
13359 ItemListerDialog(current_item,true).show();
13360 if(current_item != lister_sel_val)
13361 {
13362 if(lister_sel_val>=0)
13363 {
13364 saved = false;
13365 Map.CurrScr()->item = lister_sel_val;
13366 Map.CurrScr()->hasitem = true;
13367 }
13368 else
13369 {
13370 saved = false;
13371 Map.CurrScr()->hasitem = false;
13372 }
13373 }
13374
13375 refresh(rMAP+rMENU);
13376 return D_O_K;
13377 }
13378
13379 void call_room_dlg(mapscr* scr);
13380 int32_t onRoom()
13381 {
13382 restore_mouse();
13383 auto* scr = Map.CurrScr();
13384 call_room_dlg(scr);
13385
13386 refresh(rMAP+rMENU);
13387 return D_O_K;
13388 }
13389
13390 int32_t onEndString()
13391 {
13392 int32_t ret=select_data("Select Ending String",QMisc.endstring,msgslist,get_zc_font(font_lfont));
13393
13394 if(ret>=0)
13395 {
13396 saved=false;
13397 QMisc.endstring=msglistcache[ret];
13398 }
13399
13400 refresh(rMENU);
13401 return D_O_K;
13402 }
13403
13404 12 static ListData levelnum_list(levelnumlist, &font);
13405
13406 static DIALOG screen_pal_dlg[] =
13407 {
13408 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
13409 12 { jwin_win_proc, 60-12, 40, 200-16, 96, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Select Palette", NULL, NULL },
13410 12 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
13411 12 { jwin_droplist_proc, 72-12, 84+4, 161, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, D_EXIT, 0, 0, (void *) &levelnum_list, NULL, NULL },
13412 12 { jwin_button_proc, 70, 111, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
13413 12 { jwin_button_proc, 150, 111, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
13414 12 { jwin_text_proc, 72-12, 60+4, 168, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Note: This does not affect how the", NULL, NULL },
13415 12 { jwin_text_proc, 72-12, 72+4, 168, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "room will be displayed in-game!", NULL, NULL },
13416 12 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
13417 };
13418 // return list_dlg[2].d1;
13419
13420 int32_t onScreenPalette()
13421 {
13422 restore_mouse();
13423 screen_pal_dlg[0].dp2=get_zc_font(font_lfont);
13424 auto oldcol = screen_pal_dlg[2].d1 = Map.getcolor();
13425
13426 large_dialog(screen_pal_dlg);
13427 auto old_valid = Map.CurrScr()->valid;
13428 pause_dlg_tint(true);
13429 zq_set_screen_never_freeze(true);
13430 while(true)
13431 {
13432 auto ret = do_zqdialog(screen_pal_dlg,2);
13433 if(ret == 2)
13434 {
13435 Map.setcolor(screen_pal_dlg[2].d1);
13436 refresh(rALL);
13437 }
13438 else
13439 {
13440 if(ret == 3)
13441 {
13442 if(screen_pal_dlg[2].d1 != oldcol)
13443 saved=false;
13444 Map.setcolor(screen_pal_dlg[2].d1);
13445 }
13446 else
13447 {
13448 Map.setcolor(oldcol);
13449 Map.CurrScr()->valid = old_valid;
13450 }
13451 refresh(rALL);
13452 break;
13453 }
13454 }
13455 pause_dlg_tint(false);
13456 zq_set_screen_never_freeze(false);
13457
13458 rebuild_trans_table();
13459
13460 return D_O_K;
13461 }
13462
13463 int32_t onDecScrPal()
13464 {
13465 if(DisableLPalShortcuts)
13466 {
13467 lpal_dsa();
13468 return D_O_K;
13469 }
13470 restore_mouse();
13471 int32_t c=Map.getcolor();
13472 c+=511;
13473 c=c%512;
13474 Map.setcolor(c);
13475 refresh(rALL);
13476 saved = false;
13477 return D_O_K;
13478 }
13479
13480 int32_t onIncScrPal()
13481 {
13482 if(DisableLPalShortcuts)
13483 {
13484 lpal_dsa();
13485 return D_O_K;
13486 }
13487 restore_mouse();
13488 int32_t c=Map.getcolor();
13489 c+=1;
13490 c=c%512;
13491 Map.setcolor(c);
13492 refresh(rALL);
13493 saved = false;
13494 return D_O_K;
13495 }
13496
13497 int32_t PalWrap(int32_t kX, int32_t const kLowerBound, int32_t const kUpperBound)
13498 {
13499 int32_t range_size = kUpperBound - kLowerBound + 1;
13500
13501 if (kX < kLowerBound)
13502 kX += range_size * ((kLowerBound - kX) / range_size + 1);
13503
13504 return kLowerBound + (kX - kLowerBound) % range_size;
13505 }
13506
13507 int32_t onDecScrPal16()
13508 {
13509 if(DisableLPalShortcuts)
13510 {
13511 lpal_dsa();
13512 return D_O_K;
13513 }
13514 restore_mouse();
13515 int32_t c=Map.getcolor();
13516
13517 c = PalWrap( ( c-0x10 ), 0, 511 );
13518
13519 Map.setcolor(c);
13520 refresh(rALL);
13521 saved = false;
13522 return D_O_K;
13523 }
13524
13525 int32_t onIncScrPal16()
13526 {
13527 if(DisableLPalShortcuts)
13528 {
13529 lpal_dsa();
13530 return D_O_K;
13531 }
13532 restore_mouse();
13533 int32_t c=Map.getcolor();
13534
13535 c = PalWrap( ( c+0x10 ), 0, 511 );
13536 Map.setcolor(c);
13537 refresh(rALL);
13538 saved = false;
13539 return D_O_K;
13540 }
13541
13542 int32_t onZoomIn()
13543 {
13544 change_mapscr_zoom(-1);
13545 return D_O_K;
13546 }
13547
13548 int32_t onZoomOut()
13549 {
13550 change_mapscr_zoom(1);
13551 return D_O_K;
13552 }
13553
13554 int32_t d_ndroplist_proc(int32_t msg,DIALOG *d,int32_t c)
13555 {
13556 int32_t ret = jwin_droplist_proc(msg,d,c);
13557
13558 // The only place this proc is used is in the info type editor.
13559 // If it's ever used anywhere else, this will probably need to be changed.
13560 // Maybe add a flag for it or something.
13561 int32_t msgID=msg_at_pos(d->d1);
13562
13563 switch(msg)
13564 {
13565 case MSG_DRAW:
13566 case MSG_CHAR:
13567 case MSG_CLICK:
13568 textprintf_ex(screen,font,d->x - 48,d->y + 4,jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%5d",msgID);
13569 }
13570
13571 return ret;
13572 }
13573
13574 int32_t d_idroplist_proc(int32_t msg,DIALOG *d,int32_t c)
13575 {
13576 int32_t ret = jwin_droplist_proc(msg,d,c);
13577
13578 switch(msg)
13579 {
13580 case MSG_DRAW:
13581 case MSG_CHAR:
13582 case MSG_CLICK:
13583 int32_t tile = bii[d->d1].i >=0 ? itemsbuf[bii[d->d1].i].tile : 0;
13584 int32_t cset = bii[d->d1].i >=0 ? itemsbuf[bii[d->d1].i].csets&15 : 0;
13585 int32_t x = d->x + d->w + 4;
13586 int32_t y = d->y - 8;
13587 int32_t w = 32;
13588 int32_t h = 32;
13589
13590 BITMAP *buf = create_bitmap_ex(8,16,16);
13591 BITMAP *bigbmp = create_bitmap_ex(8,w,h);
13592
13593 if(buf && bigbmp)
13594 {
13595 clear_bitmap(buf);
13596
13597 if(tile)
13598 overtile16(buf, tile,0,0,cset,0);
13599
13600 stretch_blit(buf, bigbmp, 0,0, 16, 16, 0, 0, w, h);
13601 destroy_bitmap(buf);
13602 jwin_draw_frame(screen,x,y,w+4,h+4,FR_DEEP);
13603 blit(bigbmp,screen,0,0,x+2,y+2,w,h);
13604 destroy_bitmap(bigbmp);
13605 }
13606
13607 }
13608
13609 return ret;
13610 }
13611
13612 int32_t d_nidroplist_proc(int32_t msg,DIALOG *d,int32_t c)
13613 {
13614 int32_t ret = d_idroplist_proc(msg,d,c);
13615
13616 switch(msg)
13617 {
13618 case MSG_DRAW:
13619 case MSG_CHAR:
13620 case MSG_CLICK:
13621 textprintf_ex(screen,font,d->x - 48,d->y + 4,jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%5d",bii[d->d1].i);
13622 }
13623
13624 return ret;
13625 }
13626
13627 // Triforce pieces
13628 static byte triframe_points[9*4] =
13629 {
13630 0,2,2,0, 2,0,4,2, 0,2,4,2, 1,1,3,1, 2,0,2,2,
13631 1,1,1,2, 1,1,2,2, 3,1,3,2, 3,1,2,2
13632 };
13633
13634 int32_t d_tri_frame_proc(int32_t msg,DIALOG *d,int32_t c)
13635 {
13636 //these are here to bypass compiler warnings about unused arguments
13637 c=c;
13638
13639 if(msg==MSG_DRAW)
13640 {
13641 int32_t x[5],y[3];
13642
13643 x[0]=d->x;
13644 x[1]=d->x+(d->w>>2);
13645 x[2]=d->x+(d->w>>1);
13646 x[3]=d->x+(d->w>>1)+(d->w>>2);
13647 x[4]=d->x+d->w;
13648 y[0]=d->y;
13649 y[1]=d->y+(d->h>>1);
13650 y[2]=d->y+d->h;
13651
13652 byte *p = triframe_points;
13653
13654 for(int32_t i=0; i<9; i++)
13655 {
13656 line(screen,x[*p],y[*(p+1)],x[*(p+2)],y[*(p+3)],d->fg);
13657 p+=4;
13658 }
13659 }
13660
13661 return D_O_K;
13662 }
13663
13664 int32_t d_tri_edit_proc(int32_t msg,DIALOG *d,int32_t c)
13665 {
13666 jwin_button_proc(msg,d,c);
13667
13668 if(msg==MSG_CLICK)
13669 {
13670 int32_t v = getnumber("Piece Number",d->d1);
13671
13672 if(v>=0)
13673 {
13674 bound(v,1,8);
13675
13676 if(v!=d->d1)
13677 {
13678 DIALOG *tp = d - d->d2;
13679
13680 for(int32_t i=0; i<8; i++)
13681 {
13682 if(tp->d1==v)
13683 {
13684 tp->d1 = d->d1;
13685 ((char*)(tp->dp))[0] = d->d1+'0';
13686 jwin_button_proc(MSG_DRAW,tp,0);
13687 }
13688
13689 ++tp;
13690 }
13691
13692 d->d1 = v;
13693 ((char*)(d->dp))[0] = v+'0';
13694 }
13695 }
13696
13697 d->flags = 0;
13698 jwin_button_proc(MSG_DRAW,d,0);
13699 }
13700
13701 return D_O_K;
13702 }
13703
13704 static DIALOG tp_dlg[] =
13705 {
13706 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
13707 12 { jwin_win_proc, 56, 32, 208, 160, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Triforce Pieces", NULL, NULL },
13708 12 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
13709 12 { d_tri_frame_proc, 64, 56, 192, 96, jwin_pal[jcBOXFG], jwin_pal[jcBOX], 0, 0, 0, 0, NULL, NULL, NULL },
13710 // 3
13711 12 { d_tri_edit_proc, 138, 82, 17, 17, vc(14), vc(1), 0, 0, 0, 0, (void *) "1", NULL, NULL },
13712 12 { d_tri_edit_proc, 166, 82, 17, 17, vc(14), vc(1), 0, 0, 0, 1, (void *) "2", NULL, NULL },
13713 12 { d_tri_edit_proc, 90, 130, 17, 17, vc(14), vc(1), 0, 0, 0, 2, (void *) "3", NULL, NULL },
13714 12 { d_tri_edit_proc, 214, 130, 17, 17, vc(14), vc(1), 0, 0, 0, 3, (void *) "4", NULL, NULL },
13715 // 7
13716 12 { d_tri_edit_proc, 138, 110, 17, 17, vc(14), vc(1), 0, 0, 0, 4, (void *) "5", NULL, NULL },
13717 12 { d_tri_edit_proc, 118, 130, 17, 17, vc(14), vc(1), 0, 0, 0, 5, (void *) "6", NULL, NULL },
13718 12 { d_tri_edit_proc, 166, 110, 17, 17, vc(14), vc(1), 0, 0, 0, 6, (void *) "7", NULL, NULL },
13719 12 { d_tri_edit_proc, 186, 130, 17, 17, vc(14), vc(1), 0, 0, 0, 7, (void *) "8", NULL, NULL },
13720 // 11
13721 12 { jwin_button_proc, 90, 166, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
13722 12 { jwin_button_proc, 170, 166, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
13723 12 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
13724 };
13725
13726 int32_t onTriPieces()
13727 {
13728 tp_dlg[0].dp2=get_zc_font(font_lfont);
13729 char temptext[8][2];
13730
13731 for(int32_t i=0; i<8; i++)
13732 {
13733 tp_dlg[i+3].d1 = QMisc.triforce[i];
13734 // ((char*)(tp_dlg[i+3].dp))[0] = QMisc.triforce[i]+'0';
13735 sprintf(temptext[i], "%d", QMisc.triforce[i]);
13736 tp_dlg[i+3].dp=temptext[i];
13737 }
13738
13739 large_dialog(tp_dlg);
13740
13741 if(do_zqdialog(tp_dlg,-1) == 11)
13742 {
13743 saved=false;
13744
13745 for(int32_t i=0; i<8; i++)
13746 QMisc.triforce[i] = tp_dlg[i+3].d1;
13747 }
13748
13749 return D_O_K;
13750 }
13751
13752 int32_t d_maptile_proc(int32_t msg,DIALOG *d,int32_t c);
13753 bool small_dmap=false;
13754
13755 static DIALOG dmapmaps_dlg[] =
13756 {
13757
13758 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
13759 { jwin_win_proc, 4, 18, 313, 217, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Custom DMap Map Styles", NULL, NULL },
13760 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
13761 { jwin_button_proc, 93, 208, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
13762 { jwin_button_proc, 168, 208, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
13763 { d_ctext2_proc, 160, 38, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Minimaps", NULL, NULL },
13764 { d_ctext2_proc, 112, 46, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Without Map", NULL, NULL },
13765 { d_ctext2_proc, 208, 46, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "With Map", NULL, NULL },
13766
13767 { d_ctext2_proc, 162, 110, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Large Maps", NULL, NULL },
13768 { d_ctext2_proc, 80, 118, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Without Map", NULL, NULL },
13769 { d_ctext2_proc, 240, 118, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "With Map", NULL, NULL },
13770 // 5
13771 { d_maptile_proc, 72, 54, 80, 48, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
13772 { d_maptile_proc, 168, 54, 80, 48, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
13773 { d_maptile_proc, 8, 126, 144, 80, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
13774 { d_maptile_proc, 168, 126, 144, 80, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
13775 // 11
13776 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
13777 };
13778
13779 int32_t d_hexedit_proc(int32_t msg,DIALOG *d,int32_t c)
13780 {
13781 return jwin_hexedit_proc(msg,d,c);
13782 }
13783
13784 void drawgrid(BITMAP *dest,int32_t x,int32_t y,int32_t grid,int32_t fg,int32_t bg,int32_t div)
13785 {
13786 if(div!=-1)
13787 rectfill(dest,x-1,y-1,x+63,y+3,div);
13788
13789 for(int32_t dx=0; dx<64; dx+=8)
13790 {
13791 if(grid&0x80)
13792 rectfill(dest,x+dx,y,x+dx+6,y+2,fg);
13793 else if(bg!=-1)
13794 rectfill(dest,x+dx,y,x+dx+6,y+2,bg);
13795
13796 grid<<=1;
13797 }
13798 }
13799
13800 void drawovergrid(BITMAP *dest,int32_t x,int32_t y,int32_t grid,int32_t color,int32_t div)
13801 {
13802 if(div!=-1)
13803 rectfill(dest,x-1,y-1,x+63,y+3,div);
13804
13805 for(int32_t dx=0; dx<64; dx+=4)
13806 {
13807 rectfill(dest,x+dx,y,x+dx+2,y+2,color);
13808 grid<<=1;
13809 }
13810 }
13811
13812 void drawgrid(BITMAP *dest,int32_t x,int32_t y,int32_t w, int32_t h, int32_t tw, int32_t th, int32_t *grid,int32_t fg,int32_t bg,int32_t div)
13813 {
13814 //these are here to bypass compiler warnings about unused arguments
13815 w=w;
13816 tw=tw;
13817 th=th;
13818
13819 rectfill(dest,x,y,x+(8*8),y+(1*4),div);
13820
13821 for(int32_t dy=0; dy<h; dy++)
13822 {
13823 for(int32_t dx=0; dx<64; dx+=8)
13824 {
13825 if(grid[0]&0x80)
13826 rectfill(dest,x+dx,y,x+dx+6,y+2,fg);
13827 else
13828 rectfill(dest,x+dx,y,x+dx+6,y+2,bg);
13829
13830 grid[0]<<=1;
13831 }
13832 }
13833 }
13834
13835 void drawgrid_s(BITMAP *dest,int32_t x,int32_t y,int32_t grid,int32_t fg,int32_t bg,int32_t div)
13836 {
13837 rectfill(dest,x-1,y-1,x+63,y+3,div);
13838
13839 for(int32_t dx=0; dx<64; dx+=8)
13840 {
13841 rectfill(dest,x+dx,y,x+dx+6,y+2,bg);
13842
13843 if(grid&0x80)
13844 rectfill(dest,x+dx+2,y,x+dx+4,y+2,fg);
13845
13846 grid<<=1;
13847 }
13848 }
13849
13850 void drawdmap(int32_t dmap)
13851 {
13852 int32_t c;
13853 zcolors mc=QMisc.colors;
13854
13855 switch((DMaps[dmap].type&dmfTYPE))
13856 {
13857 case dmDNGN:
13858 case dmCAVE:
13859 clear_bitmap(dmapbmp_small);
13860
13861 if(DMaps[dmap].minimap_tile[1])
13862 ;
13863 // overworld_map_tile overrides the NES minimap. dungeon_map_tile does not.
13864 else for(int32_t y=1; y<33; y+=4)
13865 drawgrid(dmapbmp_small,0,y,DMaps[dmap].grid[y>>2], DMaps[dmap].flags&dmfMINIMAPCOLORFIX ? mc.cave_fg : mc.dngn_fg, -1, -1);
13866
13867 c=DMaps[dmap].compass;
13868 // rectfill(dmapbmp,(c&15)*8+3,(c>>4)*4+1,(c&15)*8+5,(c>>4)*4+3,dvc(2*4));
13869 rectfill(dmapbmp_small,(c&15)*8+3,(c>>4)*4+1,(c&15)*8+5,(c>>4)*4+3,vc(4));
13870 c=DMaps[dmap].cont;
13871 rectfill(dmapbmp_small,(c&15)*8+3,(c>>4)*4+1,(c&15)*8+5,(c>>4)*4+3,vc(10));
13872 break;
13873
13874 case dmOVERW:
13875 clear_bitmap(dmapbmp_small);
13876
13877 if(DMaps[dmap].minimap_tile[1])
13878 ;
13879 else if(!mc.overworld_map_tile)
13880 for(int32_t y=1; y<33; y+=4)
13881 drawovergrid(dmapbmp_small,1,y,DMaps[dmap].grid[y>>2],mc.overw_bg,vc(0));
13882
13883 c=DMaps[dmap].cont;
13884 rectfill(dmapbmp_small,(c&15)*4+1,(c>>4)*4+1,(c&15)*4+3,(c>>4)*4+3,vc(10));
13885 break;
13886
13887 case dmBSOVERW:
13888 clear_bitmap(dmapbmp_small);
13889
13890 if(DMaps[dmap].minimap_tile[1])
13891 ;
13892 else if(!mc.overworld_map_tile)
13893 for(int32_t y=1; y<33; y+=4)
13894 // drawgrid_s(dmapbmp,1,y,DMaps[dmap].grid[y>>2],dvc(2*4),dvc(2*3),dvc(3+4));
13895 drawgrid_s(dmapbmp_small,0,y,DMaps[dmap].grid[y>>2],mc.bs_goal,mc.bs_dk,vc(14));
13896
13897 c=DMaps[dmap].cont;
13898 rectfill(dmapbmp_small,(c&15)*8+3,(c>>4)*4+1,(c&15)*8+5,(c>>4)*4+3,vc(10));
13899 break;
13900 }
13901 }
13902
13903 void drawdmap_screen(int32_t x, int32_t y, int32_t w, int32_t h, int32_t dmap)
13904 {
13905 BITMAP *tempbmp = create_bitmap_ex(8,w,h);
13906 clear_to_color(tempbmp, vc(0));
13907 zcolors mc=QMisc.colors;
13908
13909 // rectfill(tempbmp,x,y,x+w-1,y+h-1,vc(0));
13910
13911 if(DMaps[dmap].minimap_tile[1])
13912 {
13913 draw_block(tempbmp,0,0,DMaps[dmap].minimap_tile[1],DMaps[dmap].minimap_cset[1],5,3);
13914 }
13915 else if(((DMaps[dmap].type&dmfTYPE)==dmDNGN || (DMaps[dmap].type&dmfTYPE)==dmCAVE) && mc.dungeon_map_tile)
13916 {
13917 draw_block(tempbmp,0,0,mc.dungeon_map_tile,mc.dungeon_map_cset,5,3);
13918 }
13919 else if(((DMaps[dmap].type&dmfTYPE)==dmOVERW || (DMaps[dmap].type&dmfTYPE)==dmBSOVERW) && mc.overworld_map_tile)
13920 {
13921 draw_block(tempbmp,0,0,mc.overworld_map_tile,mc.overworld_map_cset,5,3);
13922 }
13923
13924 masked_blit(dmapbmp_small,tempbmp,0,0,8,7,65,33);
13925
13926 blit(tempbmp,screen,0,0,x,y,w,h);
13927 destroy_bitmap(tempbmp);
13928
13929 }
13930
13931 int32_t d_dmaplist_proc(int32_t msg,DIALOG *d,int32_t c)
13932 {
13933 if(msg==MSG_DRAW)
13934 {
13935 int32_t dmap = d->d1;
13936 int32_t xy[6] = {44,92,128,100,128,110};
13937 //int32_t *xy = (int32_t*)(d->dp3);
13938 float temp_scale = 1.5;
13939
13940 drawdmap(dmap);
13941
13942 if(xy[0]>-1000&&xy[1]>-1000)
13943 {
13944 int32_t x = d->x+int32_t((xy[0]-2)*temp_scale);
13945 int32_t y = d->y+int32_t((xy[1]-2)*temp_scale);
13946 int32_t w = 84;
13947 int32_t h = 52;
13948 jwin_draw_frame(screen,x,y,w,h,FR_DEEP);
13949 drawdmap_screen(x+2,y+2,w-4,h-4,dmap);
13950 }
13951
13952 if(xy[2]>-1000&&xy[3]>-1000)
13953 {
13954 textprintf_ex(screen,get_zc_font(font_lfont_l),d->x+int32_t((xy[2])*temp_scale),d->y+int32_t((xy[3])*temp_scale),jwin_pal[jcBOXFG],jwin_pal[jcBOX],"Map: %-3d",DMaps[d->d1].map+1);
13955 }
13956
13957 if(xy[4]>-1000&&xy[5]>-1000)
13958 {
13959 textprintf_ex(screen,get_zc_font(font_lfont_l),d->x+int32_t((xy[4])*temp_scale),d->y+int32_t((xy[5])*temp_scale),jwin_pal[jcBOXFG],jwin_pal[jcBOX],"Level: %-3d",DMaps[d->d1].level);
13960 }
13961 }
13962
13963 return jwin_list_proc(msg,d,c);
13964 }
13965
13966 int32_t d_dropdmaplist_proc(int32_t msg,DIALOG *d,int32_t c)
13967 {
13968 if(msg==MSG_DRAW)
13969 {
13970 int32_t dmap = d->d1;
13971 int32_t *xy = (int32_t*)(d->dp3);
13972 float temp_scale = 1.5;
13973
13974 drawdmap(dmap);
13975
13976 if(xy[0]>-1000&&xy[1]>-1000)
13977 {
13978 int32_t x = d->x+int32_t((xy[0]-2)*temp_scale);
13979 int32_t y = d->y+int32_t((xy[1]-2)*temp_scale);
13980 int32_t w = 84;
13981 int32_t h = 52;
13982 jwin_draw_frame(screen,x,y,w,h,FR_DEEP);
13983 drawdmap_screen(x+2,y+2,w-4,h-4,dmap);
13984 }
13985
13986 if(xy[2]>-1000&&xy[3]>-1000)
13987 {
13988 textprintf_ex(screen,get_zc_font(font_lfont_l),d->x+int32_t((xy[2])*temp_scale),d->y+int32_t((xy[3])*temp_scale),jwin_pal[jcBOXFG],jwin_pal[jcBOX],"Map: %-3d",DMaps[d->d1].map+1);
13989 }
13990
13991 if(xy[4]>-1000&&xy[5]>-1000)
13992 {
13993 textprintf_ex(screen,get_zc_font(font_lfont_l),d->x+int32_t((xy[4])*temp_scale),d->y+int32_t((xy[5])*temp_scale),jwin_pal[jcBOXFG],jwin_pal[jcBOX],"Level: %-3d",DMaps[d->d1].level);
13994 }
13995 }
13996
13997 return jwin_droplist_proc(msg,d,c);
13998 }
13999
14000 void drawxmap(ALLEGRO_BITMAP* dest, int32_t themap, int32_t xoff, bool large, int dx, int dy)
14001 {
14002 ALLEGRO_STATE old_state;
14003 al_store_state(&old_state, ALLEGRO_STATE_TARGET_BITMAP);
14004
14005 al_set_target_bitmap(dest);
14006 al_clear_to_color(al_map_rgba(0, 0, 0, 0));
14007
14008 int32_t cols = (large ? 8 : 16);
14009 int32_t col_width = large ? 22 : 11;
14010 int32_t dot_width = (large ? 6 : 4);
14011 int32_t dot_offset = (large ? 7 : 3);
14012 int32_t l = 10;
14013
14014 for (int32_t y = 0; y < 8; y++)
14015 {
14016 // Users might have set the dmap to a map that has since been deleted.
14017 if (themap >= Map.getMapCount())
14018 break;
14019
14020 for (int32_t x = 0; x < cols; x++)
14021 {
14022 if (x + xoff < 0 || x + xoff > 15)
14023 continue;
14024
14025 const mapscr* scr = get_canonical_scr(themap, y * 16 + x + (large ? xoff : 0));
14026 if (!(scr->valid & mVALID))
14027 continue;
14028
14029 al_draw_filled_rectangle(dx + (x * col_width), dy + (y * l), dx + (x * col_width + col_width), dy + ((y * l) + l), real_lc1(scr->color));
14030 al_draw_filled_rectangle(dx + (x * col_width + dot_offset), dy + (y * l + 3), dx + (x * col_width + dot_offset + dot_width), dy + (y * l + l - 3), real_lc2(scr->color));
14031 }
14032 }
14033
14034 al_restore_state(&old_state);
14035 }
14036
14037 const char *dmapscriptdroplist(int32_t index, int32_t *list_size)
14038 {
14039 if(index<0)
14040 {
14041 *list_size = bidmaps_cnt;
14042 return NULL;
14043 }
14044
14045 return bidmaps[index].first.c_str();
14046 }
14047
14048 12 static ListData dmapscript_list(dmapscriptdroplist, &a4fonts[font_pfont]);
14049
14050 //int32_t selectdmapxy[6] = {90,142,164,150,164,160};
14051 int32_t selectdmapxy[6] = {44,92,128,100,128,110};
14052
14053 12 static ListData dmap_list(dmaplist, &font);
14054
14055 12 static dmap copiedDMap;
14056 static byte dmapcopied = 0;
14057
14058 int32_t writesomedmaps(PACKFILE *f, int32_t first, int32_t last, int32_t max)
14059 {
14060
14061 dword section_version=V_DMAPS;
14062 int32_t zversion = ZELDA_VERSION;
14063 int32_t zbuild = VERSION_BUILD;
14064
14065 if(!p_iputl(V_ZDMAP,f))
14066 {
14067 return 0;
14068 }
14069
14070 //section version info
14071 if(!p_iputl(zversion,f))
14072 {
14073 return 0;
14074 }
14075 if(!p_iputl(zbuild,f))
14076 {
14077 return 0;
14078 }
14079 if(!p_iputw(section_version,f))
14080 {
14081 new_return(2);
14082 }
14083
14084 if(!write_deprecated_section_cversion(section_version, f))
14085 {
14086 new_return(3);
14087 }
14088 //max possible at this time
14089 if(!p_iputl(max,f))
14090 {
14091 new_return(4);
14092 }
14093 //first id written
14094 if(!p_iputl(first,f))
14095 {
14096 new_return(5);
14097 }
14098 //last id written
14099 if(!p_iputl(last,f))
14100 {
14101 new_return(6);
14102 }
14103 int32_t count = last-first;
14104 //number written
14105 if(!p_iputl(count,f))
14106 {
14107 new_return(7);
14108 }
14109
14110
14111 for ( int32_t i = first; i <= last; ++i )
14112 {
14113 if ( i > max ) break;
14114
14115 if(!p_putc(DMaps[i].map,f))
14116 {
14117 new_return(8);
14118 }
14119
14120 if(!p_iputw(DMaps[i].level,f))
14121 {
14122 new_return(9);
14123 }
14124
14125 if(!p_putc(DMaps[i].xoff,f))
14126 {
14127 new_return(10);
14128 }
14129
14130 if(!p_putc(DMaps[i].compass,f))
14131 {
14132 new_return(11);
14133 }
14134
14135 if(!p_iputw(DMaps[i].color,f))
14136 {
14137 new_return(12);
14138 }
14139
14140 if(!p_putc(DMaps[i].midi,f))
14141 {
14142 new_return(13);
14143 }
14144
14145 if(!p_putc(DMaps[i].cont,f))
14146 {
14147 new_return(14);
14148 }
14149
14150 if(!p_putc(DMaps[i].type,f))
14151 {
14152 new_return(15);
14153 }
14154
14155 for(int32_t j=0; j<8; j++)
14156 {
14157 if(!p_putc(DMaps[i].grid[j],f))
14158 {
14159 new_return(16);
14160 }
14161 }
14162
14163 //16
14164 if(!pfwrite(&DMaps[i].name,sizeof(DMaps[0].name),f))
14165 {
14166 new_return(17);
14167 }
14168
14169 if(!p_putwstr(DMaps[i].title,f))
14170 {
14171 new_return(18);
14172 }
14173
14174 if(!pfwrite(&DMaps[i].intro,sizeof(DMaps[0].intro),f))
14175 {
14176 new_return(19);
14177 }
14178
14179 if(!p_iputl(DMaps[i].minimap_tile[0],f))
14180 {
14181 new_return(20);
14182 }
14183
14184 if(!p_putc(DMaps[i].minimap_cset[0],f))
14185 {
14186 new_return(21);
14187 }
14188
14189 if(!p_iputl(DMaps[i].minimap_tile[1],f))
14190 {
14191 new_return(22);
14192 }
14193
14194 if(!p_putc(DMaps[i].minimap_cset[1],f))
14195 {
14196 new_return(23);
14197 }
14198
14199 if(!p_iputl(DMaps[i].largemap_tile[0],f))
14200 {
14201 new_return(24);
14202 }
14203
14204 if(!p_putc(DMaps[i].largemap_cset[0],f))
14205 {
14206 new_return(25);
14207 }
14208
14209 if(!p_iputl(DMaps[i].largemap_tile[1],f))
14210 {
14211 new_return(26);
14212 }
14213
14214 if(!p_putc(DMaps[i].largemap_cset[1],f))
14215 {
14216 new_return(27);
14217 }
14218
14219 if(!pfwrite(&DMaps[i].tmusic,sizeof(DMaps[0].tmusic),f))
14220 {
14221 new_return(28);
14222 }
14223
14224 if(!p_putc(DMaps[i].tmusictrack,f))
14225 {
14226 new_return(29);
14227 }
14228
14229 if(!p_putc(DMaps[i].active_subscreen,f))
14230 {
14231 new_return(30);
14232 }
14233
14234 if(!p_putc(DMaps[i].passive_subscreen,f))
14235 {
14236 new_return(31);
14237 }
14238
14239 byte disabled[32];
14240 memset(disabled,0,32);
14241
14242 for(int32_t j=0; j<MAXITEMS; j++)
14243 {
14244 if(DMaps[i].disableditems[j])
14245 {
14246 disabled[j/8] |= (1 << (j%8));
14247 }
14248 }
14249
14250 if(!pfwrite(disabled,32,f))
14251 {
14252 new_return(32);
14253 }
14254
14255 if(!p_iputl(DMaps[i].flags,f))
14256 {
14257 new_return(33);
14258 }
14259 if(!p_putc(DMaps[i].sideview,f))
14260 {
14261 new_return(30);
14262 }
14263 if(!p_iputw(DMaps[i].script,f))
14264 {
14265 new_return(31);
14266 }
14267 for ( int32_t q = 0; q < 8; q++ )
14268 {
14269 if(!p_iputl(DMaps[i].initD[q],f))
14270 {
14271 new_return(32);
14272 }
14273
14274 }
14275 for ( int32_t q = 0; q < 8; q++ )
14276 {
14277 for ( int32_t w = 0; w < 65; w++ )
14278 {
14279 if (!p_putc(DMaps[i].initD_label[q][w],f))
14280 {
14281 new_return(33);
14282 }
14283 }
14284 }
14285 if(!p_iputw(DMaps[i].active_sub_script,f))
14286 {
14287 new_return(34);
14288 }
14289 if(!p_iputw(DMaps[i].passive_sub_script,f))
14290 {
14291 new_return(35);
14292 }
14293 for(int32_t q = 0; q < 8; ++q)
14294 {
14295 if(!p_iputl(DMaps[i].sub_initD[q],f))
14296 {
14297 new_return(36);
14298 }
14299 }
14300 for(int32_t q = 0; q < 8; ++q)
14301 {
14302 for(int32_t w = 0; w < 65; ++w)
14303 {
14304 if(!p_putc(DMaps[i].sub_initD_label[q][w],f))
14305 {
14306 new_return(37);
14307 }
14308 }
14309 }
14310 if(!p_iputw(DMaps[i].onmap_script,f))
14311 {
14312 new_return(35);
14313 }
14314 for(int32_t q = 0; q < 8; ++q)
14315 {
14316 if(!p_iputl(DMaps[i].onmap_initD[q],f))
14317 {
14318 new_return(36);
14319 }
14320 }
14321 for(int32_t q = 0; q < 8; ++q)
14322 {
14323 for(int32_t w = 0; w < 65; ++w)
14324 {
14325 if(!p_putc(DMaps[i].onmap_initD_label[q][w],f))
14326 {
14327 new_return(37);
14328 }
14329 }
14330 }
14331 if (!p_iputw(DMaps[i].mirrorDMap, f))
14332 {
14333 new_return(38);
14334 }
14335 if (!p_iputl(DMaps[i].tmusic_loop_start, f))
14336 {
14337 new_return(39);
14338 }
14339 if (!p_iputl(DMaps[i].tmusic_loop_end, f))
14340 {
14341 new_return(40);
14342 }
14343 if (!p_iputl(DMaps[i].tmusic_xfade_in, f))
14344 {
14345 new_return(41);
14346 }
14347 if (!p_iputl(DMaps[i].tmusic_xfade_out, f))
14348 {
14349 new_return(42);
14350 }
14351 }
14352
14353 return 1;
14354 }
14355
14356
14357 int32_t readsomedmaps(PACKFILE *f)
14358 {
14359 dword section_version = 0;
14360 int32_t zversion = 0;
14361 int32_t zbuild = 0;
14362 dmap tempdmap{};
14363
14364 int32_t first = 0, last = 0, max = 0, count = 0;
14365 int32_t datatype_version = 0;
14366
14367 //char dmapstring[64]={0};
14368 //section version info
14369 if(!p_igetl(&datatype_version,f))
14370 {
14371 return 0;
14372 }
14373 if ( datatype_version < 0 )
14374 {
14375 if(!p_igetl(&zversion,f))
14376 {
14377 return 0;
14378 }
14379 }
14380 else
14381 {
14382 zversion = datatype_version;
14383 }
14384 if(!p_igetl(&zbuild,f))
14385 {
14386 return 0;
14387 }
14388
14389 if(!p_igetw(&section_version,f))
14390 {
14391 return 0;
14392 }
14393
14394 if(!read_deprecated_section_cversion(f))
14395 {
14396 return 0;
14397 }
14398 if ( datatype_version < 0 )
14399 {
14400 if(!p_igetl(&max,f))
14401 {
14402 return 0;
14403 }
14404 if(!p_igetl(&first,f))
14405 {
14406 return 0;
14407 }
14408 if(!p_igetl(&last,f))
14409 {
14410 return 0;
14411 }
14412 if(!p_igetl(&count,f))
14413 {
14414 return 0;
14415 }
14416 }
14417 else
14418 {
14419 first = 0;
14420 last = 0;
14421 count = 1;
14422 max = 255;
14423 }
14424
14425
14426
14427
14428 al_trace("readsomedmaps section_version: %d\n", section_version);
14429
14430 if ( zversion > ZELDA_VERSION )
14431 {
14432 al_trace("Cannot read .zdmap packfile made in ZC version (%x) in this version of ZC (%x)\n", zversion, ZELDA_VERSION);
14433 return 0;
14434 }
14435 else if (( section_version > V_DMAPS ))
14436 {
14437 al_trace("Cannot read .zdmap packfile made using V_DMAPS (%d)\n", section_version);
14438 return 0;
14439 }
14440 else
14441 {
14442 al_trace("Reading a .zdmap packfile made in ZC Version: %x, Build: %d\n", zversion, zbuild);
14443 }
14444 //if(!pfread(&dmapstring, 64, f))
14445 //{
14446 // return 0;
14447 //}
14448
14449
14450
14451 for ( int32_t i = first; i <= last; ++i )
14452 {
14453 if(!p_getc(&tempdmap.map,f))
14454 {
14455 return 0;
14456 }
14457
14458 if(!p_igetw(&tempdmap.level,f))
14459 {
14460 return 0;
14461 }
14462
14463 if(!p_getc(&tempdmap.xoff,f))
14464 {
14465 return 0;
14466 }
14467
14468 if(!p_getc(&tempdmap.compass,f))
14469 {
14470 return 0;
14471 }
14472
14473 if(!p_igetw(&tempdmap.color,f))
14474 {
14475 return 0;
14476 }
14477
14478 if(!p_getc(&tempdmap.midi,f))
14479 {
14480 return 0;
14481 }
14482
14483 if(!p_getc(&tempdmap.cont,f))
14484 {
14485 return 0;
14486 }
14487
14488 if(!p_getc(&tempdmap.type,f))
14489 {
14490 return 0;
14491 }
14492
14493 for(int32_t j=0; j<8; j++)
14494 {
14495 if(!p_getc(&tempdmap.grid[j],f))
14496 {
14497 return 0;
14498 }
14499 }
14500
14501 //16
14502 if(!pfread(&tempdmap.name,sizeof(DMaps[0].name),f))
14503 {
14504 return 0;
14505 }
14506
14507 if (section_version<20)
14508 {
14509 char title[22];
14510 if (!p_getstr(title, sizeof(title) - 1, f))
14511 {
14512 return 0;
14513 }
14514 tempdmap.title.assign(title);
14515 }
14516 else
14517 {
14518 if (!p_getwstr(&tempdmap.title, f))
14519 {
14520 return 0;
14521 }
14522 }
14523
14524 if(!pfread(&tempdmap.intro,sizeof(DMaps[0].intro),f))
14525 {
14526 return 0;
14527 }
14528
14529 if(!p_igetl(&tempdmap.minimap_tile[0],f))
14530 {
14531 return 0;
14532 }
14533
14534 if(!p_getc(&tempdmap.minimap_cset[0],f))
14535 {
14536 return 0;
14537 }
14538
14539 if(!p_igetl(&tempdmap.minimap_tile[1],f))
14540 {
14541 return 0;
14542 }
14543
14544 if(!p_getc(&tempdmap.minimap_cset[1],f))
14545 {
14546 return 0;
14547 }
14548
14549 if(!p_igetl(&tempdmap.largemap_tile[0],f))
14550 {
14551 return 0;
14552 }
14553
14554 if(!p_getc(&tempdmap.largemap_cset[0],f))
14555 {
14556 return 0;
14557 }
14558
14559 if(!p_igetl(&tempdmap.largemap_tile[1],f))
14560 {
14561 return 0;
14562 }
14563
14564 if(!p_getc(&tempdmap.largemap_cset[1],f))
14565 {
14566 return 0;
14567 }
14568
14569 if(!pfread(&tempdmap.tmusic,sizeof(DMaps[0].tmusic),f))
14570 {
14571 return 0;
14572 }
14573
14574 if(!p_getc(&tempdmap.tmusictrack,f))
14575 {
14576 return 0;
14577 }
14578
14579 if(!p_getc(&tempdmap.active_subscreen,f))
14580 {
14581 return 0;
14582 }
14583
14584 if(!p_getc(&tempdmap.passive_subscreen,f))
14585 {
14586 return 0;
14587 }
14588
14589 byte disabled[32];
14590 memset(disabled,0,32);
14591
14592 if(!pfread(&disabled, 32, f)) return 0;
14593
14594 for(int32_t j=0; j<MAXITEMS; j++)
14595 {
14596 if(disabled[j/8] & (1 << (j%8))) tempdmap.disableditems[j]=1;
14597 else tempdmap.disableditems[j]=0;
14598 }
14599
14600
14601 if(!p_igetl(&tempdmap.flags,f))
14602 {
14603 return 0;
14604 }
14605 if ( zversion >= 0x255 )
14606 {
14607 if ( section_version >= 14 )
14608 {
14609 //2.55 starts here
14610 if(!p_getc(&tempdmap.sideview,f))
14611 {
14612 return 0;
14613 }
14614 if(!p_igetw(&tempdmap.script,f))
14615 {
14616 return 0;
14617 }
14618 for ( int32_t q = 0; q < 8; q++ )
14619 {
14620 if(!p_igetl(&tempdmap.initD[q],f))
14621 {
14622 return 0;
14623 }
14624
14625 }
14626 for ( int32_t q = 0; q < 8; q++ )
14627 {
14628 for ( int32_t w = 0; w < 65; w++ )
14629 {
14630 if (!p_getc(&tempdmap.initD_label[q][w],f))
14631 {
14632 return 0;
14633 }
14634 }
14635 }
14636 if(!p_igetw(&tempdmap.active_sub_script,f))
14637 {
14638 return 0;
14639 }
14640 if(!p_igetw(&tempdmap.passive_sub_script,f))
14641 {
14642 return 0;
14643 }
14644 for(int32_t q = 0; q < 8; ++q)
14645 {
14646 if(!p_igetl(&tempdmap.sub_initD[q],f))
14647 {
14648 return 0;
14649 }
14650 }
14651 for(int32_t q = 0; q < 8; ++q)
14652 {
14653 for(int32_t w = 0; w < 65; ++w)
14654 {
14655 if(!p_getc(&tempdmap.sub_initD_label[q][w],f))
14656 {
14657 return 0;
14658 }
14659 }
14660 }
14661 if(!p_igetw(&tempdmap.onmap_script,f))
14662 {
14663 return 0;
14664 }
14665 for(int32_t q = 0; q < 8; ++q)
14666 {
14667 if(!p_igetl(&tempdmap.onmap_initD[q],f))
14668 {
14669 return 0;
14670 }
14671 }
14672 for(int32_t q = 0; q < 8; ++q)
14673 {
14674 for(int32_t w = 0; w < 65; ++w)
14675 {
14676 if(!p_getc(&tempdmap.onmap_initD_label[q][w],f))
14677 {
14678 return 0;
14679 }
14680 }
14681 }
14682 if (!p_igetw(&tempdmap.mirrorDMap, f))
14683 {
14684 return 0;
14685 }
14686 if (!p_igetl(&tempdmap.tmusic_loop_start, f))
14687 {
14688 return 0;
14689 }
14690 if (!p_igetl(&tempdmap.tmusic_loop_end, f))
14691 {
14692 return 0;
14693 }
14694 if (!p_igetl(&tempdmap.tmusic_xfade_in, f))
14695 {
14696 return 0;
14697 }
14698 if (!p_igetl(&tempdmap.tmusic_xfade_out, f))
14699 {
14700 return 0;
14701 }
14702 }
14703 }
14704 DMaps[i].clear();
14705 DMaps[i] = tempdmap;
14706 }
14707
14708 return 1;
14709 }
14710
14711
14712
14713 int32_t writeonedmap(PACKFILE *f, int32_t i)
14714 {
14715
14716 dword section_version=V_DMAPS;
14717 int32_t zversion = ZELDA_VERSION;
14718 int32_t zbuild = VERSION_BUILD;
14719
14720
14721 //section version info
14722 if(!p_iputl(V_ZDMAP,f))
14723 {
14724 return 0;
14725 }
14726 if(!p_iputl(zversion,f))
14727 {
14728 return 0;
14729 }
14730 if(!p_iputl(zbuild,f))
14731 {
14732 return 0;
14733 }
14734 if(!p_iputw(section_version,f))
14735 {
14736 new_return(2);
14737 }
14738
14739 if(!write_deprecated_section_cversion(section_version, f))
14740 {
14741 new_return(3);
14742 }
14743
14744
14745
14746 if(!p_putc(DMaps[i].map,f))
14747 {
14748 new_return(6);
14749 }
14750
14751 if(!p_iputw(DMaps[i].level,f))
14752 {
14753 new_return(7);
14754 }
14755
14756 if(!p_putc(DMaps[i].xoff,f))
14757 {
14758 new_return(8);
14759 }
14760
14761 if(!p_putc(DMaps[i].compass,f))
14762 {
14763 new_return(9);
14764 }
14765
14766 if(!p_iputw(DMaps[i].color,f))
14767 {
14768 new_return(10);
14769 }
14770
14771 if(!p_putc(DMaps[i].midi,f))
14772 {
14773 new_return(11);
14774 }
14775
14776 if(!p_putc(DMaps[i].cont,f))
14777 {
14778 new_return(12);
14779 }
14780
14781 if(!p_putc(DMaps[i].type,f))
14782 {
14783 new_return(13);
14784 }
14785
14786 for(int32_t j=0; j<8; j++)
14787 {
14788 if(!p_putc(DMaps[i].grid[j],f))
14789 {
14790 new_return(14);
14791 }
14792 }
14793
14794 //16
14795 if(!pfwrite(&DMaps[i].name,sizeof(DMaps[0].name),f))
14796 {
14797 new_return(15);
14798 }
14799
14800 if(!pfwrite(&DMaps[i].title,sizeof(DMaps[0].title),f))
14801 {
14802 new_return(16);
14803 }
14804
14805 if(!pfwrite(&DMaps[i].intro,sizeof(DMaps[0].intro),f))
14806 {
14807 new_return(17);
14808 }
14809
14810 if(!p_iputl(DMaps[i].minimap_tile[0],f))
14811 {
14812 new_return(18);
14813 }
14814
14815 if(!p_putc(DMaps[i].minimap_cset[0],f))
14816 {
14817 new_return(19);
14818 }
14819
14820 if(!p_iputl(DMaps[i].minimap_tile[1],f))
14821 {
14822 new_return(20);
14823 }
14824
14825 if(!p_putc(DMaps[i].minimap_cset[1],f))
14826 {
14827 new_return(21);
14828 }
14829
14830 if(!p_iputl(DMaps[i].largemap_tile[0],f))
14831 {
14832 new_return(22);
14833 }
14834
14835 if(!p_putc(DMaps[i].largemap_cset[0],f))
14836 {
14837 new_return(23);
14838 }
14839
14840 if(!p_iputl(DMaps[i].largemap_tile[1],f))
14841 {
14842 new_return(24);
14843 }
14844
14845 if(!p_putc(DMaps[i].largemap_cset[1],f))
14846 {
14847 new_return(25);
14848 }
14849
14850 if(!pfwrite(&DMaps[i].tmusic,sizeof(DMaps[0].tmusic),f))
14851 {
14852 new_return(26);
14853 }
14854
14855 if(!p_putc(DMaps[i].tmusictrack,f))
14856 {
14857 new_return(25);
14858 }
14859
14860 if(!p_putc(DMaps[i].active_subscreen,f))
14861 {
14862 new_return(26);
14863 }
14864
14865 if(!p_putc(DMaps[i].passive_subscreen,f))
14866 {
14867 new_return(27);
14868 }
14869
14870 byte disabled[32];
14871 memset(disabled,0,32);
14872
14873 for(int32_t j=0; j<MAXITEMS; j++)
14874 {
14875 if(DMaps[i].disableditems[j])
14876 {
14877 disabled[j/8] |= (1 << (j%8));
14878 }
14879 }
14880
14881 if(!pfwrite(disabled,32,f))
14882 {
14883 new_return(28);
14884 }
14885
14886 if(!p_iputl(DMaps[i].flags,f))
14887 {
14888 new_return(29);
14889 }
14890 if(!p_putc(DMaps[i].sideview,f))
14891 {
14892 new_return(30);
14893 }
14894 if(!p_iputw(DMaps[i].script,f))
14895 {
14896 new_return(31);
14897 }
14898 for ( int32_t q = 0; q < 8; q++ )
14899 {
14900 if(!p_iputl(DMaps[i].initD[q],f))
14901 {
14902 new_return(32);
14903 }
14904
14905 }
14906 for ( int32_t q = 0; q < 8; q++ )
14907 {
14908 for ( int32_t w = 0; w < 65; w++ )
14909 {
14910 if (!p_putc(DMaps[i].initD_label[q][w],f))
14911 {
14912 new_return(33);
14913 }
14914 }
14915 }
14916 if(!p_iputw(DMaps[i].active_sub_script,f))
14917 {
14918 new_return(34);
14919 }
14920 if(!p_iputw(DMaps[i].passive_sub_script,f))
14921 {
14922 new_return(35);
14923 }
14924 for(int32_t q = 0; q < 8; ++q)
14925 {
14926 if(!p_iputl(DMaps[i].sub_initD[q],f))
14927 {
14928 new_return(36);
14929 }
14930 }
14931 for(int32_t q = 0; q < 8; ++q)
14932 {
14933 for(int32_t w = 0; w < 65; ++w)
14934 {
14935 if(!p_putc(DMaps[i].sub_initD_label[q][w],f))
14936 {
14937 new_return(37);
14938 }
14939 }
14940 }
14941 if(!p_iputw(DMaps[i].onmap_script,f))
14942 {
14943 new_return(35);
14944 }
14945 for(int32_t q = 0; q < 8; ++q)
14946 {
14947 if(!p_iputl(DMaps[i].onmap_initD[q],f))
14948 {
14949 new_return(36);
14950 }
14951 }
14952 for(int32_t q = 0; q < 8; ++q)
14953 {
14954 for(int32_t w = 0; w < 65; ++w)
14955 {
14956 if(!p_putc(DMaps[i].onmap_initD_label[q][w],f))
14957 {
14958 new_return(37);
14959 }
14960 }
14961 }
14962 if (!p_iputw(DMaps[i].mirrorDMap, f))
14963 {
14964 new_return(38);
14965 }
14966 if (!p_iputl(DMaps[i].tmusic_loop_start, f))
14967 {
14968 new_return(39);
14969 }
14970 if (!p_iputl(DMaps[i].tmusic_loop_end, f))
14971 {
14972 new_return(40);
14973 }
14974 if (!p_iputl(DMaps[i].tmusic_xfade_in, f))
14975 {
14976 new_return(41);
14977 }
14978 if (!p_iputl(DMaps[i].tmusic_xfade_out, f))
14979 {
14980 new_return(42);
14981 }
14982
14983 return 1;
14984 }
14985
14986
14987 int32_t readonedmap(PACKFILE *f, int32_t index)
14988 {
14989 dword section_version = 0;
14990 int32_t zversion = 0;
14991 int32_t zbuild = 0;
14992 dmap tempdmap{};
14993 int32_t datatype_version = 0;
14994 int32_t first = 0;
14995 int32_t last = 0;
14996 int32_t max = 0;
14997 int32_t count = 0;
14998
14999 //char dmapstring[64]={0};
15000 //section version info
15001 if(!p_igetl(&datatype_version,f))
15002 {
15003 return 0;
15004 }
15005 if ( datatype_version < 0 )
15006 {
15007 if(!p_igetl(&zversion,f))
15008 {
15009 return 0;
15010 }
15011 }
15012 else
15013 {
15014 zversion = datatype_version;
15015 }
15016 if(!p_igetl(&zbuild,f))
15017 {
15018 return 0;
15019 }
15020
15021 if(!p_igetw(&section_version,f))
15022 {
15023 return 0;
15024 }
15025
15026 if(!read_deprecated_section_cversion(f))
15027 {
15028 return 0;
15029 }
15030 al_trace("readonedmap section_version: %d\n", section_version);
15031
15032
15033 if ( datatype_version < 0 )
15034 {
15035 if(!p_igetl(&max,f))
15036 {
15037 return 0;
15038 }
15039 if(!p_igetl(&first,f))
15040 {
15041 return 0;
15042 }
15043 if(!p_igetl(&last,f))
15044 {
15045 return 0;
15046 }
15047 if(!p_igetl(&count,f))
15048 {
15049 return 0;
15050 }
15051 }
15052 if ( zversion > ZELDA_VERSION )
15053 {
15054 al_trace("Cannot read .zdmap packfile made in ZC version (%x) in this version of ZC (%x)\n", zversion, ZELDA_VERSION);
15055 return 0;
15056 }
15057 else if (( section_version > V_DMAPS ))
15058 {
15059 al_trace("Cannot read .zdmap packfile made using V_DMAPS (%d)\n", section_version);
15060 return 0;
15061 }
15062 else
15063 {
15064 al_trace("Reading a .zdmap packfile made in ZC Version: %x, Build: %d\n", zversion, zbuild);
15065 }
15066 //if(!pfread(&dmapstring, 64, f))
15067 //{
15068 // return 0;
15069 //}
15070
15071
15072
15073
15074 if(!p_getc(&tempdmap.map,f))
15075 {
15076 return 0;
15077 }
15078
15079 if(!p_igetw(&tempdmap.level,f))
15080 {
15081 return 0;
15082 }
15083
15084 if(!p_getc(&tempdmap.xoff,f))
15085 {
15086 return 0;
15087 }
15088
15089 if(!p_getc(&tempdmap.compass,f))
15090 {
15091 return 0;
15092 }
15093
15094 if(!p_igetw(&tempdmap.color,f))
15095 {
15096 return 0;
15097 }
15098
15099 if(!p_getc(&tempdmap.midi,f))
15100 {
15101 return 0;
15102 }
15103
15104 if(!p_getc(&tempdmap.cont,f))
15105 {
15106 return 0;
15107 }
15108
15109 if(!p_getc(&tempdmap.type,f))
15110 {
15111 return 0;
15112 }
15113
15114 for(int32_t j=0; j<8; j++)
15115 {
15116 if(!p_getc(&tempdmap.grid[j],f))
15117 {
15118 return 0;
15119 }
15120 }
15121
15122 //16
15123 if(!pfread(&tempdmap.name,sizeof(DMaps[0].name),f))
15124 {
15125 return 0;
15126 }
15127
15128 if (section_version<20)
15129 {
15130 char title[22];
15131 if (!p_getstr(title, sizeof(title) - 1, f))
15132 {
15133 return 0;
15134 }
15135 tempdmap.title.assign(title);
15136 }
15137 else
15138 {
15139 if (!p_getwstr(&tempdmap.title, f))
15140 {
15141 return 0;
15142 }
15143 }
15144
15145 if(!pfread(&tempdmap.title,sizeof(DMaps[0].title),f))
15146 {
15147 return 0;
15148 }
15149
15150 if(!pfread(&tempdmap.intro,sizeof(DMaps[0].intro),f))
15151 {
15152 return 0;
15153 }
15154
15155 if(!p_igetl(&tempdmap.minimap_tile[0],f))
15156 {
15157 return 0;
15158 }
15159
15160 if(!p_getc(&tempdmap.minimap_cset[0],f))
15161 {
15162 return 0;
15163 }
15164
15165 if(!p_igetl(&tempdmap.minimap_tile[1],f))
15166 {
15167 return 0;
15168 }
15169
15170 if(!p_getc(&tempdmap.minimap_cset[1],f))
15171 {
15172 return 0;
15173 }
15174
15175 if(!p_igetl(&tempdmap.largemap_tile[0],f))
15176 {
15177 return 0;
15178 }
15179
15180 if(!p_getc(&tempdmap.largemap_cset[0],f))
15181 {
15182 return 0;
15183 }
15184
15185 if(!p_igetl(&tempdmap.largemap_tile[1],f))
15186 {
15187 return 0;
15188 }
15189
15190 if(!p_getc(&tempdmap.largemap_cset[1],f))
15191 {
15192 return 0;
15193 }
15194
15195 if(!pfread(&tempdmap.tmusic,sizeof(DMaps[0].tmusic),f))
15196 {
15197 return 0;
15198 }
15199
15200 if(!p_getc(&tempdmap.tmusictrack,f))
15201 {
15202 return 0;
15203 }
15204
15205 if(!p_getc(&tempdmap.active_subscreen,f))
15206 {
15207 return 0;
15208 }
15209
15210 if(!p_getc(&tempdmap.passive_subscreen,f))
15211 {
15212 return 0;
15213 }
15214
15215 byte disabled[32];
15216 memset(disabled,0,32);
15217
15218 if(!pfread(&disabled, 32, f)) return 0;
15219
15220 for(int32_t j=0; j<MAXITEMS; j++)
15221 {
15222 if(disabled[j/8] & (1 << (j%8))) tempdmap.disableditems[j]=1;
15223 else tempdmap.disableditems[j]=0;
15224 }
15225
15226
15227 if(!p_igetl(&tempdmap.flags,f))
15228 {
15229 return 0;
15230 }
15231 if ( zversion >= 0x255 )
15232 {
15233 if ( section_version >= 14 )
15234 {
15235 //2.55 starts here
15236 if(!p_getc(&tempdmap.sideview,f))
15237 {
15238 return 0;
15239 }
15240 if(!p_igetw(&tempdmap.script,f))
15241 {
15242 return 0;
15243 }
15244 for ( int32_t q = 0; q < 8; q++ )
15245 {
15246 if(!p_igetl(&tempdmap.initD[q],f))
15247 {
15248 return 0;
15249 }
15250
15251 }
15252 for ( int32_t q = 0; q < 8; q++ )
15253 {
15254 for ( int32_t w = 0; w < 65; w++ )
15255 {
15256 if (!p_getc(&tempdmap.initD_label[q][w],f))
15257 {
15258 return 0;
15259 }
15260 }
15261 }
15262 if(!p_igetw(&tempdmap.active_sub_script,f))
15263 {
15264 return 0;
15265 }
15266 if(!p_igetw(&tempdmap.passive_sub_script,f))
15267 {
15268 return 0;
15269 }
15270 for(int32_t q = 0; q < 8; ++q)
15271 {
15272 if(!p_igetl(&tempdmap.sub_initD[q],f))
15273 {
15274 return 0;
15275 }
15276 }
15277 for(int32_t q = 0; q < 8; ++q)
15278 {
15279 for(int32_t w = 0; w < 65; ++w)
15280 {
15281 if(!p_getc(&tempdmap.sub_initD_label[q][w],f))
15282 {
15283 return 0;
15284 }
15285 }
15286 }
15287 if(!p_igetw(&tempdmap.onmap_script,f))
15288 {
15289 return 0;
15290 }
15291 for(int32_t q = 0; q < 8; ++q)
15292 {
15293 if(!p_igetl(&tempdmap.onmap_initD[q],f))
15294 {
15295 return 0;
15296 }
15297 }
15298 for(int32_t q = 0; q < 8; ++q)
15299 {
15300 for(int32_t w = 0; w < 65; ++w)
15301 {
15302 if(!p_getc(&tempdmap.onmap_initD_label[q][w],f))
15303 {
15304 return 0;
15305 }
15306 }
15307 }
15308 if (!p_igetw(&tempdmap.mirrorDMap, f))
15309 {
15310 return 0;
15311 }
15312 if (!p_igetl(&tempdmap.tmusic_loop_start, f))
15313 {
15314 return 0;
15315 }
15316 if (!p_igetl(&tempdmap.tmusic_loop_end, f))
15317 {
15318 return 0;
15319 }
15320 if (!p_igetl(&tempdmap.tmusic_xfade_in, f))
15321 {
15322 return 0;
15323 }
15324 if (!p_igetl(&tempdmap.tmusic_xfade_out, f))
15325 {
15326 return 0;
15327 }
15328 }
15329 }
15330 DMaps[index] = tempdmap;
15331
15332 return 1;
15333 }
15334
15335 int32_t onDmaps()
15336 {
15337 DMapListerDialog(0).show();
15338 return D_O_K;
15339 }
15340
15341 int32_t onRegions()
15342 {
15343 bool valid = false;
15344 for (int i = 0; i < MAPSCRS; i++)
15345 {
15346 if (Map.Scr(i)->is_valid())
15347 {
15348 valid = true;
15349 break;
15350 }
15351 }
15352
15353 if (valid)
15354 {
15355 call_edit_region_dialog(Map.getCurrMap());
15356 Map.regions_mark_dirty();
15357 }
15358 else
15359 {
15360 InfoDialog("Invalid maps", "There must be at least one valid screen in a map to configure regions").show();
15361 }
15362
15363 return D_O_K;
15364 }
15365
15366 int32_t onMidis()
15367 {
15368 stopMusic();
15369 MidiListerDialog().show();
15370 return D_O_K;
15371 }
15372
15373 static DIALOG editmusic_dlg[] =
15374 {
15375 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
15376 { jwin_win_proc, 24, 20, 273, 189, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Music Specs", NULL, NULL },
15377 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
15378 // 2
15379 { jwin_text_proc, 56, 94-16, 48, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Music:", NULL, NULL },
15380 { jwin_text_proc, 104, 94-16, 48, 8, vc(11), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
15381 { jwin_text_proc, 56, 114, 48, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Name:", NULL, NULL },
15382 { jwin_edit_proc, 104, 114-4, 160, 16, vc(12), vc(1), 0, 0, 19, 0, NULL, NULL, NULL },
15383 { jwin_text_proc, 56, 124-4+12, 56, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Volume:", NULL, NULL },
15384 { jwin_edit_proc, 120, 124-4+12-4, 32, 16, vc(12), vc(1), 0, 0, 3, 0, NULL, NULL, NULL },
15385 // 8
15386 { jwin_check_proc, 176, 124+12-4, 80+1, 8+1, vc(14), vc(1), 0, 0, 1, 0, (void *) "Loop", NULL, NULL },
15387 // 9
15388 { jwin_button_proc, 50, 72-24, 57, 21, vc(14), vc(1), 'l', D_EXIT, 0, 0, (void *) "&Load", NULL, NULL },
15389 { jwin_iconbutton_proc, 116, 72-24, 33, 21, vc(14), vc(1), 0, D_EXIT, BTNICON_STOPSQUARE, 0, NULL, NULL, NULL },
15390 { jwin_iconbutton_proc, 156, 72-24, 33, 21, vc(14), vc(1), 0, D_EXIT, BTNICON_ARROW_RIGHT, 0, NULL, NULL, NULL },
15391 { jwin_iconbutton_proc, 196, 72-24, 33, 21, vc(14), vc(1), 0, D_EXIT, BTNICON_ARROW_RIGHT2, 0, NULL, NULL, NULL },
15392 { jwin_iconbutton_proc, 236, 72-24, 33, 21, vc(14), vc(1), 0, D_EXIT, BTNICON_ARROW_RIGHT3, 0, NULL, NULL, NULL },
15393 // 14
15394 { jwin_text_proc, 56, 134+4+12, 48, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start:", NULL, NULL },
15395 { jwin_edit_proc, 112, 134+12, 32, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
15396 { jwin_text_proc, 176, 134+12+4, 56, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Loop Start:", NULL, NULL },
15397 { jwin_edit_proc, 240, 134+12, 40, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
15398 { jwin_text_proc, 176, 144+12+12, 48, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Loop End:", NULL, NULL },
15399 { jwin_edit_proc, 240, 144+12+12-4, 40, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
15400 // 20
15401 { jwin_text_proc, 176, 94-16, 48, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Position:", NULL, NULL },
15402 { jwin_text_proc, 217, 94-16, 32, 8, vc(11), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
15403 { jwin_text_proc, 176, 104-8, 48, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Length:", NULL, NULL },
15404 { jwin_text_proc, 216, 104-8, 32, 8, vc(11), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
15405 { jwin_text_proc, 56, 104-8, 48, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Time:", NULL, NULL },
15406 { jwin_text_proc, 104, 104-8, 32, 8, vc(11), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
15407 // 26
15408 { jwin_button_proc, 90, 160+12+12, 61, 21, vc(14), vc(1), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
15409 { jwin_button_proc, 170, 160+12+12, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
15410 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onHelp, NULL, NULL },
15411 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
15412 };
15413
15414 int32_t d_musiclist_proc(int32_t msg,DIALOG *d,int32_t c)
15415 {
15416 return jwin_list_proc(msg,d,c);
15417 }
15418
15419 12 static ListData enhancedmusic_list(enhancedmusiclist, &font);
15420
15421 static DIALOG selectmusic_dlg[] =
15422 {
15423 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
15424 12 { jwin_win_proc, 24, 20, 273, 189, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Select Enhanced Music", NULL, NULL },
15425 12 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
15426 12 { d_musiclist_proc, 31, 44, 164, (1+16)*8, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, D_EXIT, 0, 0, (void *) &enhancedmusic_list, NULL, NULL },
15427 12 { jwin_button_proc, 90, 160+12+12, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Edit", NULL, NULL },
15428 12 { jwin_button_proc, 170, 160+12+12, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Done", NULL, NULL },
15429 12 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, KEY_DEL, (void *) close_dlg, NULL, NULL },
15430 12 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
15431 };
15432
15433 const char *warptypelist(int32_t index, int32_t *list_size)
15434 {
15435 if(index>=0)
15436 {
15437 if(index>=MAXWARPTYPES)
15438 index=MAXWARPTYPES-1;
15439
15440 return warptype_string[index];
15441 }
15442
15443 *list_size=MAXWARPTYPES;
15444 // *list_size=6;
15445 return NULL;
15446 }
15447
15448 const char *warpeffectlist(int32_t index, int32_t *list_size)
15449 {
15450 if(index>=0)
15451 {
15452 if(index>=MAXWARPEFFECTS)
15453 index=MAXWARPEFFECTS-1;
15454
15455 return warpeffect_string[index];
15456 }
15457
15458 *list_size=MAXWARPEFFECTS;
15459 return NULL;
15460 }
15461
15462 static int32_t warp1_list[] =
15463 {
15464 2,3,4,5,6,7,8,9,10,11,12,13,53,54,63,67,-1
15465 };
15466
15467 static int32_t warp2_list[] =
15468 {
15469 17,18,19,20,21,22,23,24,25,26,27,28,55,56,64,68,-1
15470 };
15471
15472 static int32_t warp3_list[] =
15473 {
15474 29,30,31,32,33,34,35,36,37,38,39,40,57,58,65,69,-1
15475 };
15476
15477 static int32_t warp4_list[] =
15478 {
15479 41,42,43,44,45,46,47,48,49,50,51,52,59,60,66,70,-1
15480 };
15481
15482 static TABPANEL warp_tabs[] =
15483 {
15484 // (text)
15485 { (char *)"A", D_SELECTED, warp1_list, 0, NULL },
15486 { (char *)"B", 0, warp2_list, 0, NULL },
15487 { (char *)"C", 0, warp3_list, 0, NULL },
15488 { (char *)"D", 0, warp4_list, 0, NULL },
15489 { NULL, 0, NULL, 0, NULL }
15490 };
15491
15492 int32_t onTileWarpIndex(int32_t index)
15493 {
15494 int32_t i=-1;
15495
15496 while(warp_tabs[++i].text != NULL)
15497 warp_tabs[i].flags = (i==index ? D_SELECTED : 0);
15498
15499 onTileWarp();
15500 return D_O_K;
15501 }
15502
15503 static char warpr_buf[10];
15504 const char *warprlist(int32_t index, int32_t *list_size)
15505 {
15506 if(index>=0)
15507 {
15508 bound(index,0,3);
15509 sprintf(warpr_buf,"%c",index+0x41);
15510 return warpr_buf;
15511 }
15512
15513 *list_size=4;
15514 return NULL;
15515 }
15516
15517 int32_t d_wflag_proc(int32_t msg,DIALOG *d,int32_t c);
15518
15519 12 static ListData warp_dlg_list(warptypelist, &font);
15520 12 static ListData warp_ret_list(warprlist, &font);
15521
15522 int32_t d_warpdestscrsel_proc(int32_t msg,DIALOG *d,int32_t c)
15523 {
15524 if(msg == MSG_START)
15525 {
15526 d->d1 = -1; //cached val
15527 d->d2 = -1; //cached dmap
15528 d->fg = 0; //cached 'force_16'
15529 }
15530 char* buf = (char*)d->dp;
15531 vector<DIALOG*>* dlgs = (vector<DIALOG*>*)d->dp2;
15532 int* dmap_ptr = (int*) d->dp3;
15533 if(!(buf && dmap_ptr))
15534 return D_O_K;
15535 bool is_overworld = ((DMaps[*dmap_ptr].type&dmfTYPE)==dmOVERW);
15536 int scrw = is_overworld ? 16 : 8, scrh = 9;
15537 const int max = 0x87;
15538 int bufval = zc_xtoi(buf);
15539 int val = vbound(bufval,0,max);
15540 auto& dm = DMaps[*dmap_ptr];
15541 auto val_offset = dm.xoff < 0 ? -dm.xoff : 0;
15542 bool force_16 = d->fg;
15543 if(!is_overworld)
15544 {
15545 if((val&0xF) >= 0x8)
15546 force_16 = true;
15547 else if((val&0xF) < val_offset && (val&0xF0) < 0x80)
15548 force_16 = true;
15549 }
15550 if(force_16) //can't bound, some quests need to warp out of bounds... -Em
15551 {
15552 scrw = 16; //just force show the larger grid instead
15553 val_offset = 0;
15554 }
15555
15556 int xscl = d->w/scrw;
15557 int yscl = d->h/scrh;
15558
15559 int ret = D_O_K;
15560 bool redraw = false;
15561 if(d->d1 != val)
15562 {
15563 redraw = true;
15564 d->d1 = val;
15565 }
15566 if(bufval != val)
15567 {
15568 redraw = true;
15569 sprintf(buf, "%X", val);
15570 }
15571 if(d->d2 != *dmap_ptr)
15572 {
15573 redraw = true;
15574 d->d2 = *dmap_ptr;
15575 }
15576 switch(msg)
15577 {
15578 case MSG_WANTFOCUS:
15579 ret = D_WANTFOCUS;
15580 break;
15581 case MSG_CLICK:
15582 {
15583 d->fg = force_16 ? 1 : 0;
15584 bool redraw2 = false;
15585 while(gui_mouse_b())
15586 {
15587 if(redraw2)
15588 {
15589 broadcast_dialog_message(MSG_DRAW, 0);
15590 redraw2 = false;
15591 }
15592 if(!d->fg && (gui_mouse_b()&2))
15593 {
15594 scrw = 16;
15595 xscl = d->w/scrw;
15596 yscl = d->h/scrh;
15597 val_offset = 0;
15598 d->fg = 1;
15599 redraw2 = true;
15600 }
15601 custom_vsync();
15602 if(!mouse_in_rect(d->x,d->y,d->w,d->h))
15603 continue;
15604 int mx = gui_mouse_x()-d->x, my = gui_mouse_y()-d->y;
15605 int y = vbound(my/yscl,0,scrh-1);
15606 auto offs = y==8 ? 0 : val_offset;
15607 int x = vbound(mx/xscl,offs,scrw-1);
15608 auto val2 = (y*16)+x;
15609 if(val2 > max) //out of bounds in the bottom-right
15610 continue;
15611 val = val2;
15612 if(d->d1 != val)
15613 {
15614 d->d1 = val;
15615 sprintf(buf, "%02X", val);
15616 redraw2 = true;
15617 }
15618 }
15619 redraw = true;
15620 d->fg = 0;
15621 break;
15622 }
15623 case MSG_DRAW:
15624 {
15625 rectfill(screen,d->x,d->y,d->x+d->w-1,d->y+d->h-1,jwin_pal[jcBOX]);
15626 jwin_draw_frame(screen, d->x-2, d->y-2, d->w+4, d->h+4, FR_MENU);
15627 for(int yind = 0; yind < scrh; ++yind)
15628 {
15629 auto gr = (yind < 8 ? dm.grid[yind] : 0);
15630 for(int xind = (yind == 8 ? 0 : val_offset); xind < scrw; ++xind)
15631 {
15632 int screen_index = xind+(yind*16);
15633 if(screen_index > max)
15634 continue;
15635 int fr = FR_MENU;
15636 if(screen_index == d->d1)
15637 fr = FR_GREEN;
15638 else if(!is_overworld && xind < 8 && (gr&(1<<(8-xind-1))))
15639 fr = FR_MENU_INV;
15640 jwin_draw_frame(screen, d->x+(xind*xscl), d->y+(yind*yscl), xscl, yscl, fr);
15641 }
15642 }
15643 break;
15644 }
15645 case MSG_XCHAR:
15646 {
15647 bool on_80 = (val&0xF0) == 0x80;
15648 switch(c>>8)
15649 {
15650 case KEY_UP:
15651 if((val&0xF0) && !(val_offset && on_80 && (val&0xF) < val_offset))
15652 {
15653 val -= 0x10;
15654 redraw = true;
15655 }
15656 ret |= D_USED_CHAR;
15657 break;
15658 case KEY_DOWN:
15659 if((val&0xF0) < ((val&0xF) < 0x8 ? 0x80 : 0x70))
15660 {
15661 val += 0x10;
15662 redraw = true;
15663 }
15664 ret |= D_USED_CHAR;
15665 break;
15666 case KEY_LEFT:
15667 if((val&0xF) > (on_80 ? 0 : val_offset))
15668 {
15669 --val;
15670 redraw = true;
15671 }
15672 ret |= D_USED_CHAR;
15673 break;
15674 case KEY_RIGHT:
15675 if((val&0xF) < scrw-1 && val < 0x87)
15676 {
15677 ++val;
15678 redraw = true;
15679 }
15680 ret |= D_USED_CHAR;
15681 break;
15682 }
15683 if(redraw)
15684 sprintf(buf, "%02X", val);
15685 break;
15686 }
15687 }
15688 if(redraw)
15689 {
15690 if(msg == MSG_IDLE)
15691 broadcast_dialog_message(MSG_DRAW,0);
15692 else
15693 {
15694 d->d1 = d->d2 = -1;
15695 object_message(d,MSG_IDLE,0);
15696 }
15697 }
15698
15699 return ret;
15700 }
15701
15702 int32_t tilewarpdmapxy[6] = {170,38,170,18,170,27};
15703 static DIALOG tilewarp_dlg[] =
15704 {
15705 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
15706 12 { jwin_win_proc, 0, 0, 302, 178, vc(14), vc(1), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
15707 12 { jwin_rtext_proc, 89, 43, 40, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Type:", NULL, NULL },
15708 12 { jwin_rtext_proc, 57, 62, 40, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "DMap:", NULL, NULL },
15709 12 { jwin_rtext_proc, 57, 80, 64, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Screen: 0x", NULL, NULL },
15710 12 { jwin_droplist_proc, 91, 38, 193, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &warp_dlg_list, NULL, NULL },
15711 //5
15712 12 { d_dropdmaplist_proc, 59, 57, 225, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &dmap_list, NULL, tilewarpdmapxy },
15713 12 { jwin_hexedit_proc, 59, 76, 24, 16, vc(12), vc(1), 0, 0, 2, 0, NULL, NULL, NULL },
15714 12 { jwin_button_proc, 61, 152, 41, 21, vc(14), vc(1), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
15715 12 { jwin_button_proc, 121, 152, 41, 21, vc(14), vc(1), 'g', D_EXIT, 0, 0, (void *) "&Go", NULL, NULL },
15716 12 { jwin_button_proc, 181, 152, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
15717 //10
15718 12 { jwin_rtext_proc, 82, 95, 100, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Use Warp Return:", NULL, NULL },
15719 12 { jwin_droplist_proc, 10, 105, 72, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &warp_ret_list, NULL, NULL },
15720 12 { jwin_check_proc, 10, 125, 129, 9, vc(14), vc(1), 0, 0, 1, 0, (void *) "Combos Carry Over", NULL, NULL },
15721 12 { d_warpdestscrsel_proc, 90, 76, 8*16, 8*9, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
15722 12 { jwin_button_proc, 59, 21, 50, 14, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "A", NULL, NULL },
15723 //15
15724 12 { jwin_button_proc, 109, 21, 50, 14, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "B", NULL, NULL },
15725 12 { jwin_button_proc, 159, 21, 50, 14, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "C", NULL, NULL },
15726 12 { jwin_button_proc, 209, 21, 50, 14, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "D", NULL, NULL },
15727 12 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
15728 };
15729
15730 int32_t sidewarpdmapxy[6] = {170,38,170,18,170,27};
15731 static DIALOG sidewarp_dlg[] =
15732 {
15733 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
15734 12 { jwin_win_proc, 0, 0, 302, 178, vc(14), vc(1), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
15735 12 { jwin_rtext_proc, 89, 43, 40, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Type:", NULL, NULL },
15736 12 { jwin_rtext_proc, 57, 62, 40, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "DMap:", NULL, NULL },
15737 12 { jwin_rtext_proc, 57, 80, 64, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Screen: 0x", NULL, NULL },
15738 12 { jwin_droplist_proc, 91, 38, 193, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &warp_dlg_list, NULL, NULL },
15739 //5
15740 12 { d_dropdmaplist_proc, 59, 57, 225, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &dmap_list, NULL, tilewarpdmapxy },
15741 12 { jwin_hexedit_proc, 59, 76, 24, 16, vc(12), vc(1), 0, 0, 2, 0, NULL, NULL, NULL },
15742 12 { jwin_button_proc, 61, 152, 41, 21, vc(14), vc(1), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
15743 12 { jwin_button_proc, 121, 152, 41, 21, vc(14), vc(1), 'g', D_EXIT, 0, 0, (void *) "&Go", NULL, NULL },
15744 12 { jwin_button_proc, 181, 152, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
15745 //10
15746 12 { jwin_rtext_proc, 82, 95, 100, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Use Warp Return:", NULL, NULL },
15747 12 { jwin_droplist_proc, 10, 105, 72, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &warp_ret_list, NULL, NULL },
15748 12 { jwin_check_proc, 10, 125, 129, 9, vc(14), vc(1), 0, 0, 1, 0, (void *) "Combos Carry Over", NULL, NULL },
15749 12 { d_warpdestscrsel_proc, 90, 76, 8*16, 8*9, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
15750 12 { jwin_button_proc, 59, 21, 50, 14, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "A", NULL, NULL },
15751 //15
15752 12 { jwin_button_proc, 109, 21, 50, 14, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "B", NULL, NULL },
15753 12 { jwin_button_proc, 159, 21, 50, 14, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "C", NULL, NULL },
15754 12 { jwin_button_proc, 209, 21, 50, 14, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "D", NULL, NULL },
15755 // 18
15756 12 { d_wflag_proc, 18, 17, 15, 8, vc(4), vc(0), 0, 0, 1, 0, NULL, NULL, NULL },
15757 12 { d_wflag_proc, 18, 47, 15, 8, vc(4), vc(0), 0, 0, 1, 0, NULL, NULL, NULL },
15758 // 20
15759 12 { d_wflag_proc, 8, 27, 8, 15, vc(4), vc(0), 0, 0, 1, 0, NULL, NULL, NULL },
15760 12 { d_wflag_proc, 37, 27, 8, 15, vc(4), vc(0), 0, 0, 1, 0, NULL, NULL, NULL },
15761
15762 12 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
15763 };
15764
15765 int32_t warpringxy[6] = {170,38,170,18,170,27};
15766 static DIALOG warpring_warp_dlg[] =
15767 {
15768 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
15769 12 { jwin_win_proc, 0, 0, 302, 145, vc(14), vc(1), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
15770 12 { jwin_rtext_proc, 57, 25, 40, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "DMap:", NULL, NULL },
15771 12 { jwin_rtext_proc, 57, 46, 64, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Screen: 0x", NULL, NULL },
15772 12 { d_dropdmaplist_proc, 59, 19, 225, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &dmap_list, NULL, warpringxy },
15773 12 { jwin_hexedit_proc, 59, 39, 24, 16, vc(12), vc(1), 0, 0, 2, 0, NULL, NULL, NULL },
15774 // 5
15775 12 { jwin_button_proc, 61, 115, 41, 21, vc(14), vc(1), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
15776 12 { jwin_button_proc, 121, 115, 41, 21, vc(14), vc(1), 'g', D_EXIT, 0, 0, (void *) "&Go", NULL, NULL },
15777 12 { jwin_button_proc, 181, 115, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
15778 12 { d_warpdestscrsel_proc, 90, 39, 8*16, 8*9, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
15779
15780 12 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
15781 };
15782
15783 // Side warp flag procedure
15784 int32_t d_wflag_proc(int32_t msg,DIALOG *d,int32_t)
15785 {
15786 int32_t ret = D_O_K;
15787 switch(msg)
15788 {
15789 case MSG_DRAW:
15790 {
15791 int32_t c2=(d->flags&D_SELECTED)?d->fg:d->bg;
15792
15793 if(d->d1==1)
15794 {
15795 jwin_draw_frame(screen,d->x,d->y,d->w,d->h, FR_DEEP);
15796 rectfill(screen,d->x+2, d->y+2, d->x+d->w-3, d->y+d->h-3,c2);
15797
15798 if(d->flags&D_SELECTED)
15799 {
15800 int32_t e=d->d2&3;
15801
15802 if(d->w>d->h)
15803 textprintf_centre_ex(screen,get_zc_font(font_lfont_l), d->x+(d->w/2),d->y,jwin_pal[jcBOXFG],-1,"%c",e+0x41);
15804 else
15805 textprintf_centre_ex(screen,get_zc_font(font_lfont_l), d->x+(d->w/2),d->y+(d->h/2)-4,jwin_pal[jcBOXFG],-1,"%c",e+0x41);
15806 }
15807
15808 }
15809 else
15810 {
15811 rectfill(screen,d->x, d->y, d->x+d->w-1, d->y+d->h-1,c2);
15812 }
15813 }
15814 break;
15815
15816 case MSG_CLICK:
15817 {
15818 if(d->flags & D_DISABLED)
15819 return D_O_K;
15820 bool rclick = gui_mouse_b() & 2;
15821 if(d->d1==1)
15822 {
15823 if(!(d->flags&D_SELECTED))
15824 {
15825 d->flags |= D_SELECTED;
15826 d->d2 &= 0x80;
15827 if (rclick)
15828 d->d2 |= 3;
15829 }
15830 else
15831 {
15832 if((d->d2&3) == (rclick?0:3))
15833 {
15834 d->flags ^= D_SELECTED;
15835 d->d2 &= 0x80;
15836 }
15837 else
15838 {
15839 int32_t f = d->d2&3;
15840 d->d2 &= 0x80;
15841 f += rclick ? -1 : 1;
15842 d->d2 |= f;
15843 }
15844 }
15845 }
15846 else
15847 {
15848 d->flags^=D_SELECTED;
15849 }
15850
15851 int32_t c2=(d->flags&D_SELECTED)?d->fg:d->bg;
15852
15853 if(d->d1==1)
15854 {
15855 jwin_draw_frame(screen,d->x,d->y,d->w,d->h, FR_DEEP);
15856 rectfill(screen,d->x+2, d->y+2, d->x+d->w-3, d->y+d->h-3,c2);
15857
15858 if(d->flags&D_SELECTED)
15859 {
15860 int32_t e=d->d2&3;
15861
15862 if(d->w>d->h)
15863 textprintf_centre_ex(screen,get_zc_font(font_lfont_l),d->x+(d->w/2),d->y,jwin_pal[jcBOXFG],-1,"%c",e+0x41);
15864 else
15865 textprintf_centre_ex(screen,get_zc_font(font_lfont_l),d->x+(d->w/2),d->y+(d->h/2)-4,jwin_pal[jcBOXFG],-1,"%c",e+0x41);
15866 }
15867 }
15868 else
15869 {
15870 rectfill(screen,d->x, d->y, d->x+d->w-1, d->y+d->h-1,c2);
15871 }
15872
15873
15874 while(gui_mouse_b())
15875 {
15876 /* do nothing */
15877 rest(1);
15878 }
15879 ret = D_REDRAWME;
15880 }
15881 break;
15882 }
15883
15884 return ret;
15885 }
15886
15887 int32_t d_dmapscrsel_proc(int32_t msg,DIALOG *d,int32_t c)
15888 {
15889 //these are here to bypass compiler warnings about unused arguments
15890 c=c;
15891
15892 int32_t ret = D_O_K;
15893
15894 switch(msg)
15895 {
15896 case MSG_CLICK:
15897 sprintf((char*)((d+2)->dp),"%X%X",vbound((gui_mouse_y()-d->y)/4,0,7),vbound((gui_mouse_x()-d->x)/(((DMaps[(d-1)->d1].type&dmfTYPE)==1)?4:8),0,(((DMaps[(d-1)->d1].type&dmfTYPE)==1)?15:7)));
15898 object_message(d+2, MSG_DRAW, 0);
15899 break;
15900 }
15901
15902 return ret;
15903 }
15904
15905 int32_t warpdestsel_x=-1;
15906 int32_t warpdestsel_y=-1;
15907 int32_t warpdestmap=-1;
15908 int32_t warpdestscr=-1;
15909
15910 int32_t jwin_minibutton_proc(int32_t msg,DIALOG *d,int32_t c)
15911 {
15912 switch(msg)
15913 {
15914 case MSG_DRAW:
15915 jwin_draw_text_button(screen, d->x, d->y, d->w, d->h, (char*)d->dp, d->flags, false);
15916 return D_O_K;
15917 break;
15918 }
15919
15920 return jwin_button_proc(msg,d,c);
15921 }
15922
15923 int32_t d_triggerbutton_proc(int32_t msg,DIALOG *d,int32_t c)
15924 {
15925 static BITMAP *dummy=create_bitmap_ex(8, 1, 1);
15926
15927 switch(msg)
15928 {
15929 case MSG_START:
15930 d->w=gui_textout_ln(dummy, font, (uint8_t *)d->dp, 0, 0, jwin_pal[jcMEDDARK], -1, 0)+4;
15931 d->h=text_height(font)+5;
15932 break;
15933
15934 case MSG_GOTFOCUS:
15935 d->flags&=~D_GOTFOCUS;
15936 break;
15937
15938 }
15939
15940 return jwin_minibutton_proc(msg,d,c);
15941 }
15942
15943 int32_t d_alltriggerbutton_proc(int32_t msg,DIALOG *d,int32_t c)
15944 {
15945 DIALOG *temp_d;
15946 int32_t ret=d_triggerbutton_proc(msg,d,c);
15947
15948 switch(msg)
15949 {
15950 case MSG_CLICK:
15951 temp_d=d-1;
15952
15953 while(temp_d->proc==d_triggerbutton_proc)
15954 {
15955 temp_d->flags&=~D_SELECTED;
15956 temp_d->flags|=D_DIRTY;
15957
15958 if(d->flags&D_SELECTED)
15959 {
15960 temp_d->flags|=D_SELECTED;
15961 }
15962
15963 --temp_d;
15964 }
15965
15966 break;
15967 }
15968
15969 return ret;
15970 }
15971
15972 int32_t d_ticsedit_proc(int32_t msg,DIALOG *d,int32_t c)
15973 {
15974 int32_t ret = jwin_edit_proc(msg,d,c);
15975
15976 if(msg==MSG_DRAW)
15977 {
15978 int32_t tics=vbound(atoi((char*)d->dp),0,65535);
15979 sprintf((char*)(d+1)->dp,"%s %s",ticksstr(tics),tics==0?"(No Timed Warp)":" ");
15980 object_message(d+1,MSG_DRAW,c);
15981 }
15982
15983 return ret;
15984 }
15985
15986 12 static ListData warp_effect_list(warpeffectlist,&font);
15987
15988 struct tw_data
15989 {
15990 int twscr[4], twtype[4], twdmap[4], wret[4];
15991 byte oflags;
15992 optional<uint> loaded;
15993
15994 tw_data(mapscr* scr) {load_scr(scr);}
15995 void load_scr(mapscr* scr)
15996 {
15997 oflags = scr->tilewarpoverlayflags;
15998 for(int q = 0; q < 4; ++q)
15999 {
16000 twscr[q] = scr->tilewarpscr[q];
16001 twtype[q] = scr->tilewarptype[q];
16002 twdmap[q] = scr->tilewarpdmap[q];
16003 wret[q] = (scr->warpreturnc >> (2*q))&3;
16004 }
16005 loaded.reset();
16006 }
16007 void save_scr(mapscr* scr)
16008 {
16009 saved=false;
16010 scr->tilewarpoverlayflags = oflags;
16011 scr->warpreturnc = scr->warpreturnc & 0xFF00;
16012 for(int q = 0; q < 4; ++q)
16013 {
16014 scr->tilewarpscr[q] = twscr[q];
16015 scr->tilewarptype[q] = twtype[q];
16016 scr->tilewarpdmap[q] = twdmap[q];
16017 scr->warpreturnc |= wret[q] << (2*q);
16018 }
16019 }
16020
16021 void load(uint ind)
16022 {
16023 if(ind >= 4) return;
16024 loaded = ind;
16025 tilewarp_dlg[4].d1 = twtype[ind];
16026 tilewarp_dlg[5].d1 = twdmap[ind];
16027 char* buf = (char*)tilewarp_dlg[6].dp;
16028 sprintf(buf,"%02X",twscr[ind]);
16029 tilewarp_dlg[11].d1 = wret[ind];
16030 SETFLAG(tilewarp_dlg[12].flags, D_SELECTED, get_bit(&oflags,ind));
16031 for(int q = 0; q < 4; ++q)
16032 SETFLAG(tilewarp_dlg[14+q].flags,(D_SELECTED|D_DISABLED),q==ind);
16033 }
16034 void save(uint ind)
16035 {
16036 if(ind >= 4) return;
16037 twtype[ind] = tilewarp_dlg[4].d1;
16038 twdmap[ind] = tilewarp_dlg[5].d1;
16039 char* buf = (char*)tilewarp_dlg[6].dp;
16040 twscr[ind] = vbound(zc_xtoi(buf),0x00,0x87);
16041 wret[ind] = tilewarp_dlg[11].d1;
16042 set_bit(&oflags, ind, tilewarp_dlg[12].flags & D_SELECTED);
16043 }
16044 void save()
16045 {
16046 if(loaded)
16047 save(*loaded);
16048 }
16049 void swap(uint ind)
16050 {
16051 if(ind >= 4) return;
16052 if(loaded)
16053 {
16054 save(*loaded);
16055 if(*loaded == ind)
16056 return;
16057 }
16058 load(ind);
16059 }
16060 };
16061 int32_t onTileWarp()
16062 {
16063 restore_mouse();
16064 tilewarp_dlg[0].dp=(void *) "Tile Warp";
16065 tilewarp_dlg[0].dp2=get_zc_font(font_lfont);
16066
16067 mapscr* mptr = Map.CurrScr();
16068 char buf[10];
16069 tilewarp_dlg[6].dp=buf;
16070 tilewarp_dlg[13].dp = buf;
16071 tilewarp_dlg[13].dp3 = &tilewarp_dlg[5].d1;
16072
16073 vector<DIALOG*> dlgs;
16074 dlgs.push_back(&tilewarp_dlg[5]);
16075 dlgs.push_back(&tilewarp_dlg[6]);
16076 tilewarp_dlg[13].dp2 = &dlgs;
16077
16078 tw_data data(mptr);
16079 data.load(0);
16080
16081 dmap_list_size=MAXDMAPS;
16082 dmap_list_zero=true;
16083
16084 large_dialog(tilewarp_dlg);
16085
16086 bool running = true;
16087 int ret;
16088 do
16089 {
16090 ret = do_zqdialog(tilewarp_dlg,-1);
16091 switch(ret)
16092 {
16093 // OK, GO
16094 case 7: case 8:
16095 running = false;
16096 data.save();
16097 data.save_scr(mptr);
16098 refresh(rMENU);
16099 break;
16100 //Cancel
16101 case 9:
16102 running = false;
16103 break;
16104 //A,B,C,D
16105 case 14: case 15: case 16: case 17:
16106 data.swap(ret-14);
16107 break;
16108 }
16109 }
16110 while(running);
16111
16112 if(ret==8) //GO
16113 {
16114 int32_t index = *data.loaded;
16115
16116 FlashWarpSquare = -1;
16117 int32_t tm = Map.getCurrMap();
16118 int32_t ts = Map.getCurrScr();
16119 int32_t thistype = mptr->tilewarptype[index];
16120 Map.dowarp(0,index);
16121
16122 if((ts!=Map.getCurrScr() || tm!=Map.getCurrMap()) && thistype != wtCAVE && thistype != wtSCROLL)
16123 {
16124 FlashWarpSquare = (TheMaps[tm*MAPSCRS+ts].warpreturnc>>(index*2))&3;
16125 FlashWarpClk = 32;
16126 }
16127
16128 refresh(rALL);
16129 }
16130
16131 return D_O_K;
16132 }
16133
16134 struct sw_data
16135 {
16136 int swscr[4], swtype[4], swdmap[4], wret[4];
16137 byte oflags;
16138 optional<uint> loaded;
16139
16140 sw_data(mapscr* scr) {load_scr(scr);}
16141 void load_scr(mapscr* scr)
16142 {
16143 oflags = scr->sidewarpoverlayflags;
16144 for(int q = 0; q < 4; ++q)
16145 {
16146 swscr[q] = scr->sidewarpscr[q];
16147 swtype[q] = scr->sidewarptype[q];
16148 swdmap[q] = scr->sidewarpdmap[q];
16149 wret[q] = (scr->warpreturnc >> (2*(q+4)))&3;
16150 }
16151 loaded.reset();
16152
16153 for(int32_t i=0; i<4; i++)
16154 {
16155 sidewarp_dlg[18+i].d2 = 0x80;
16156 if(scr->flags2&(1<<i))
16157 {
16158 sidewarp_dlg[18+i].flags = D_SELECTED ;
16159 sidewarp_dlg[18+i].d2 |= (scr->sidewarpindex>>(2*i))&3;
16160 }
16161 else
16162 {
16163 sidewarp_dlg[18+i].flags = 0;
16164 }
16165 }
16166 }
16167 void save_scr(mapscr* scr)
16168 {
16169 saved=false;
16170 scr->sidewarpoverlayflags = oflags;
16171 scr->warpreturnc = scr->warpreturnc & 0x00FF;
16172 for(int q = 0; q < 4; ++q)
16173 {
16174 scr->sidewarpscr[q] = swscr[q];
16175 scr->sidewarptype[q] = swtype[q];
16176 scr->sidewarpdmap[q] = swdmap[q];
16177 scr->warpreturnc |= wret[q] << (2*(q+4));
16178 }
16179
16180 scr->flags2 &= ~0xF;
16181 scr->sidewarpindex = 0;
16182 for(int32_t i=0; i<4; i++)
16183 {
16184 if(sidewarp_dlg[18+i].flags & D_SELECTED)
16185 scr->flags2 |= 1<<i;
16186 scr->sidewarpindex |= (sidewarp_dlg[18+i].d2&3) << (i*2);
16187 }
16188 }
16189
16190 void load(uint ind)
16191 {
16192 if(ind >= 4) return;
16193 loaded = ind;
16194 sidewarp_dlg[4].d1 = swtype[ind];
16195 sidewarp_dlg[5].d1 = swdmap[ind];
16196 char* buf = (char*)sidewarp_dlg[6].dp;
16197 sprintf(buf,"%02X",swscr[ind]);
16198 sidewarp_dlg[11].d1 = wret[ind];
16199 SETFLAG(sidewarp_dlg[12].flags, D_SELECTED, get_bit(&oflags,ind));
16200 for(int q = 0; q < 4; ++q)
16201 SETFLAG(sidewarp_dlg[14+q].flags,(D_SELECTED|D_DISABLED),q==ind);
16202 }
16203 void save(uint ind)
16204 {
16205 if(ind >= 4) return;
16206 swtype[ind] = sidewarp_dlg[4].d1;
16207 swdmap[ind] = sidewarp_dlg[5].d1;
16208 char* buf = (char*)sidewarp_dlg[6].dp;
16209 swscr[ind] = vbound(zc_xtoi(buf),0x00,0x87);
16210 wret[ind] = sidewarp_dlg[11].d1;
16211 set_bit(&oflags, ind, sidewarp_dlg[12].flags & D_SELECTED);
16212 }
16213 void save()
16214 {
16215 if(loaded)
16216 save(*loaded);
16217 }
16218 void swap(uint ind)
16219 {
16220 if(ind >= 4) return;
16221 if(loaded)
16222 {
16223 save(*loaded);
16224 if(*loaded == ind)
16225 return;
16226 }
16227 load(ind);
16228 }
16229 };
16230 int32_t onSideWarp()
16231 {
16232 restore_mouse();
16233 sidewarp_dlg[0].dp=(void *) "Side Warp";
16234 sidewarp_dlg[0].dp2=get_zc_font(font_lfont);
16235
16236 mapscr* mptr = Map.CurrScr();
16237 char buf[10];
16238 sidewarp_dlg[6].dp=buf;
16239 sidewarp_dlg[13].dp = buf;
16240 sidewarp_dlg[13].dp3 = &sidewarp_dlg[5].d1;
16241
16242 vector<DIALOG*> dlgs;
16243 dlgs.push_back(&sidewarp_dlg[5]);
16244 dlgs.push_back(&sidewarp_dlg[6]);
16245 sidewarp_dlg[13].dp2 = &dlgs;
16246
16247 sw_data data(mptr);
16248 data.load(0);
16249
16250 dmap_list_size=MAXDMAPS;
16251 dmap_list_zero=true;
16252
16253 large_dialog(sidewarp_dlg);
16254
16255 bool running = true;
16256 int ret;
16257 do
16258 {
16259 ret = do_zqdialog(sidewarp_dlg,-1);
16260 switch(ret)
16261 {
16262 // OK, GO
16263 case 7: case 8:
16264 running = false;
16265 data.save();
16266 data.save_scr(mptr);
16267 refresh(rMENU);
16268 break;
16269 //Cancel
16270 case 9:
16271 running = false;
16272 break;
16273 //A,B,C,D
16274 case 14: case 15: case 16: case 17:
16275 data.swap(ret-14);
16276 break;
16277 }
16278 }
16279 while(running);
16280
16281 if(ret==8) //GO
16282 {
16283 int32_t index = *data.loaded;
16284
16285 FlashWarpSquare = -1;
16286 int32_t tm = Map.getCurrMap();
16287 int32_t ts = Map.getCurrScr();
16288
16289 int32_t thistype = mptr->sidewarptype[index];
16290 Map.dowarp(1,index);
16291
16292 if((ts!=Map.getCurrScr() || tm!=Map.getCurrMap()) && thistype != wtSCROLL)
16293 {
16294 FlashWarpSquare = (TheMaps[tm*MAPSCRS+ts].warpreturnc>>(8+index*2))&3;
16295 FlashWarpClk = 0x20;
16296 }
16297
16298 refresh(rALL);
16299 }
16300
16301 return D_O_K;
16302 }
16303
16304
16305
16306 const char *dirlist(int32_t index, int32_t *list_size)
16307 {
16308 if(index>=0)
16309 {
16310 if(index>3)
16311 index=3;
16312
16313 return mazedirstr[index];
16314 }
16315
16316 *list_size=4;
16317 return NULL;
16318 }
16319
16320 12 static ListData path_dlg_list(dirlist, &font);
16321
16322 static const char *wipestr[] = {"None", "Circle", "Oval", "Triangle", "SMAS", "Fade Black"};
16323 // enum {bosCIRCLE=0, bosOVAL, bosTRIANGLE, bosSMAS, bosFADEBLACK, bosMAX};
16324 const char *wipelist(int32_t index, int32_t *list_size)
16325 {
16326 if(index>=0)
16327 {
16328 if(index>5)
16329 index=5;
16330
16331 return wipestr[index];
16332 }
16333
16334 *list_size=6;
16335 return NULL;
16336 }
16337
16338 12 static ListData wipe_effect_dlg_list(wipelist, &font);
16339
16340 static DIALOG path_dlg[] =
16341 {
16342 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
16343 12 { jwin_win_proc, 80, 57, 161, 182, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Maze Path", NULL, NULL },
16344 12 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
16345 12 { jwin_text_proc, 94, 106, 192, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "1st", NULL, NULL },
16346 12 { jwin_text_proc, 94, 124, 192, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "2nd", NULL, NULL },
16347 12 { jwin_text_proc, 94, 142, 192, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "3rd", NULL, NULL },
16348 12 { jwin_text_proc, 94, 160, 192, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "4th", NULL, NULL },
16349 12 { jwin_text_proc, 94, 178, 192, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Exit", NULL, NULL },
16350 12 { jwin_text_proc, 94, 196, 192, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Wipe effect", NULL, NULL },
16351 12 { jwin_droplist_proc, 140, 102, 80+1, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &path_dlg_list, NULL, NULL },
16352 12 { jwin_droplist_proc, 140, 120, 80+1, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &path_dlg_list, NULL, NULL },
16353 12 { jwin_droplist_proc, 140, 138, 80+1, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &path_dlg_list, NULL, NULL },
16354 12 { jwin_droplist_proc, 140, 156, 80+1, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &path_dlg_list, NULL, NULL },
16355 12 { jwin_droplist_proc, 140, 174, 80+1, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &path_dlg_list, NULL, NULL },
16356 12 { jwin_droplist_proc, 140, 192, 80+1, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &wipe_effect_dlg_list, NULL, NULL },
16357 12 { jwin_button_proc, 90, 212, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
16358 12 { jwin_button_proc, 170, 212, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
16359 12 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onHelp, NULL, NULL },
16360 12 { jwin_text_proc, 87, 82, 192, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "A Lost Woods-style maze screen", NULL, NULL },
16361 12 { jwin_text_proc, 87, 92, 192, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "with a normal and secret exit.", NULL, NULL },
16362 12 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
16363 };
16364
16365 int32_t onPath()
16366 {
16367 restore_mouse();
16368 path_dlg[0].dp2=get_zc_font(font_lfont);
16369
16370 for(int32_t i=0; i<4; i++)
16371 path_dlg[i+8].d1 = Map.CurrScr()->path[i];
16372
16373 path_dlg[12].d1 = Map.CurrScr()->exitdir;
16374 path_dlg[13].d1 = Map.CurrScr()->maze_transition_wipe;
16375
16376 large_dialog(path_dlg);
16377
16378 int32_t ret;
16379
16380 do
16381 {
16382 ret=do_zqdialog(path_dlg,8);
16383
16384 if(ret==14)
16385 {
16386 for(int32_t i=0; i<4; i++)
16387 {
16388 if(path_dlg[i+8].d1 == path_dlg[12].d1)
16389 {
16390 if(jwin_alert("Exit Problem","One of the path's directions is","also the normal Exit direction! Continue?",NULL,"Yes","No",'y','n',get_zc_font(font_lfont))==2)
16391 ret = -1;
16392
16393 break;
16394 }
16395 }
16396 }
16397 }
16398 while(ret == -1);
16399
16400 if(ret==14)
16401 {
16402 saved=false;
16403
16404 for(int32_t i=0; i<4; i++)
16405 Map.CurrScr()->path[i] = path_dlg[i+8].d1;
16406
16407 Map.CurrScr()->exitdir = path_dlg[12].d1;
16408 Map.CurrScr()->maze_transition_wipe = path_dlg[13].d1;
16409
16410 if(!(Map.CurrScr()->flags&fMAZE))
16411 if(jwin_alert("Screen Flag","Turn on the 'Use Maze Path' Screen Flag?","(Go to 'Screen Data' to turn it off.)",NULL,"Yes","No",'y','n',get_zc_font(font_lfont))==1)
16412 Map.CurrScr()->flags |= fMAZE;
16413 }
16414
16415 refresh(rMAP+rMENU);
16416 return D_O_K;
16417 }
16418
16419
16420
16421 static DIALOG editinfo_dlg[] =
16422 {
16423 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
16424 12 { jwin_win_proc, 0, 10, 208, 204, vc(14), vc(1), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
16425 12 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
16426 12 { jwin_text_proc, 24, 60, 48, 8, vc(7), vc(1), 0, 0, 0, 0, (void *) "1st", NULL, NULL },
16427 12 { jwin_text_proc, 24, 106, 48, 8, vc(7), vc(1), 0, 0, 0, 0, (void *) "2nd", NULL, NULL },
16428 12 { jwin_text_proc, 24, 152, 48, 8, vc(7), vc(1), 0, 0, 0, 0, (void *) "3rd", NULL, NULL },
16429 12 { jwin_text_proc, 56, 60, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Price:", NULL, NULL },
16430 12 { jwin_text_proc, 56, 106, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Price:", NULL, NULL },
16431 12 { jwin_text_proc, 56, 152, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Price:", NULL, NULL },
16432 // 8
16433 12 { jwin_edit_proc, 86, 56, 32, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
16434 12 { d_ndroplist_proc, 56, 74, 137, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
16435 12 { jwin_edit_proc, 86, 102, 32, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
16436 12 { d_ndroplist_proc, 56, 120, 137, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
16437 12 { jwin_edit_proc, 86, 148, 32, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
16438 12 { d_ndroplist_proc, 56, 166, 137, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
16439 12 { jwin_text_proc, 24, 42, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Name:", NULL, NULL },
16440 12 { jwin_edit_proc, 56, 38, 137, 16, vc(12), vc(1), 0, 0, 31, 0, NULL, NULL, NULL },
16441 // 16
16442 12 { jwin_button_proc, 34, 188, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
16443 12 { jwin_button_proc, 114, 188, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
16444 12 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
16445 };
16446
16447 void EditInfoType(int32_t index)
16448 {
16449 char ps1[6],ps2[6],ps3[6];
16450 char infoname[33];
16451 char caption[40];
16452
16453 int32_t str1, str2, str3;
16454
16455 sprintf(caption,"Info Data %d",index);
16456 editinfo_dlg[0].dp = caption;
16457 editinfo_dlg[0].dp2 = get_zc_font(font_lfont);
16458
16459 sprintf(ps1,"%d",QMisc.info[index].price[0]);
16460 sprintf(ps2,"%d",QMisc.info[index].price[1]);
16461 sprintf(ps3,"%d",QMisc.info[index].price[2]);
16462 strncpy(infoname,QMisc.info[index].name,32);
16463 infoname[32] = 0;
16464 editinfo_dlg[8].dp = ps1;
16465 editinfo_dlg[10].dp = ps2;
16466 editinfo_dlg[12].dp = ps3;
16467 editinfo_dlg[15].dp = infoname;
16468 str1 = QMisc.info[index].str[0];
16469 str2 = QMisc.info[index].str[1];
16470 str3 = QMisc.info[index].str[2];
16471 editinfo_dlg[9].d1 = MsgStrings[str1].listpos;
16472 editinfo_dlg[11].d1 = MsgStrings[str2].listpos;
16473 editinfo_dlg[13].d1 = MsgStrings[str3].listpos;
16474 ListData msgs_list(msgslist2, &a4fonts[font_lfont_l]);
16475 editinfo_dlg[9].dp =
16476 editinfo_dlg[11].dp =
16477 editinfo_dlg[13].dp = (void *) &msgs_list;
16478
16479 large_dialog(editinfo_dlg);
16480
16481 int32_t ret = do_zqdialog(editinfo_dlg,-1);
16482
16483 if(ret==16)
16484 {
16485 saved=false;
16486 QMisc.info[index].price[0] = vbound(atoi(ps1), 0, 65535);
16487 QMisc.info[index].price[1] = vbound(atoi(ps2), 0, 65535);
16488 QMisc.info[index].price[2] = vbound(atoi(ps3), 0, 65535);
16489 strncpy(QMisc.info[index].name,infoname,32);
16490 str1 = editinfo_dlg[9].d1;
16491 str2 = editinfo_dlg[11].d1;
16492 str3 = editinfo_dlg[13].d1;
16493 QMisc.info[index].str[0] = msg_at_pos(str1);
16494 QMisc.info[index].str[1] = msg_at_pos(str2);
16495 QMisc.info[index].str[2] = msg_at_pos(str3);
16496
16497 //move 0s to the end
16498 word swaptmp;
16499
16500 if(QMisc.info[index].str[0] == 0)
16501 {
16502 //possibly permute the infos
16503 if(QMisc.info[index].str[1] != 0)
16504 {
16505 //swap
16506 swaptmp = QMisc.info[index].str[0];
16507 QMisc.info[index].str[0] = QMisc.info[index].str[1];
16508 QMisc.info[index].str[1] = swaptmp;
16509 swaptmp = QMisc.info[index].price[0];
16510 QMisc.info[index].price[0] = QMisc.info[index].price[1];
16511 QMisc.info[index].price[1] = swaptmp;
16512 }
16513 else if(QMisc.info[index].str[2] != 0)
16514 {
16515 //move info 0 to 1, 1 to 2, and 2 to 0
16516 swaptmp = QMisc.info[index].str[0];
16517 QMisc.info[index].str[0] = QMisc.info[index].str[2];
16518 QMisc.info[index].str[2] = QMisc.info[index].str[1];
16519 QMisc.info[index].str[1] = swaptmp;
16520 swaptmp = QMisc.info[index].price[0];
16521 QMisc.info[index].price[0] = QMisc.info[index].price[2];
16522 QMisc.info[index].price[2] = QMisc.info[index].price[1];
16523 QMisc.info[index].price[1] = swaptmp;
16524 }
16525 }
16526
16527 if(QMisc.info[index].str[1] == 0 && QMisc.info[index].str[2] != 0)
16528 //swap
16529 {
16530 swaptmp = QMisc.info[index].str[1];
16531 QMisc.info[index].str[1] = QMisc.info[index].str[2];
16532 QMisc.info[index].str[2] = swaptmp;
16533 swaptmp = QMisc.info[index].price[1];
16534 QMisc.info[index].price[1] = QMisc.info[index].price[2];
16535 QMisc.info[index].price[2] = swaptmp;
16536 }
16537 }
16538 }
16539
16540 int32_t onInfoTypes()
16541 {
16542 info_list_size = 256;
16543
16544 int32_t index = select_data("Info Types",0,infolist,"Edit","Done",get_zc_font(font_lfont));
16545
16546 while(index!=-1)
16547 {
16548 EditInfoType(index);
16549
16550 index = select_data("Info Types",index,infolist,"Edit","Done",get_zc_font(font_lfont));
16551 }
16552
16553 return D_O_K;
16554 }
16555
16556
16557
16558 //This dialogie is self-contained, and does not use dialogue control numbers in a separate array to generate its fields.
16559 static DIALOG editshop_dlg[] =
16560 {
16561 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
16562 12 { jwin_win_proc, 0, 10, 221, 204, vc(14), vc(1), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
16563 12 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
16564 12 { jwin_text_proc, 24, 60, 48, 8, vc(7), vc(1), 0, 0, 0, 0, (void *) "1st", NULL, NULL },
16565 12 { jwin_text_proc, 24, 106, 48, 8, vc(7), vc(1), 0, 0, 0, 0, (void *) "2nd", NULL, NULL },
16566 12 { jwin_text_proc, 24, 152, 48, 8, vc(7), vc(1), 0, 0, 0, 0, (void *) "3rd", NULL, NULL },
16567 12 { jwin_text_proc, 56, 60, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Price:", NULL, NULL },
16568 12 { jwin_text_proc, 56, 106, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Price:", NULL, NULL },
16569 12 { jwin_text_proc, 56, 152, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Price:", NULL, NULL },
16570 // 8
16571 12 { jwin_edit_proc, 86, 56, 32, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
16572 12 { d_nidroplist_proc, 56, 74, 137, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
16573 12 { jwin_edit_proc, 86, 102, 32, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
16574 12 { d_nidroplist_proc, 56, 120, 137, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
16575 12 { jwin_edit_proc, 86, 148, 32, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
16576 12 { d_nidroplist_proc, 56, 166, 137, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
16577 12 { jwin_text_proc, 24, 42, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Name:", NULL, NULL },
16578 12 { jwin_edit_proc, 56, 38, 137, 16, vc(12), vc(1), 0, 0, 31, 0, NULL, NULL, NULL },
16579
16580 // 16
16581 12 { jwin_button_proc, 40, 188, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
16582 12 { jwin_button_proc, 121, 188, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
16583 //18
16584 12 { jwin_text_proc, 130, 60, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Info:", NULL, NULL },
16585 12 { jwin_text_proc, 130, 106, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Info:", NULL, NULL },
16586 12 { jwin_text_proc, 130, 152, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Info:", NULL, NULL },
16587 // 21
16588 12 { jwin_edit_proc, 155, 56, 32, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
16589 12 { jwin_edit_proc, 155, 102, 32, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
16590 12 { jwin_edit_proc, 155, 148, 32, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
16591
16592 12 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
16593 };
16594
16595 void EditShopType(int32_t index)
16596 {
16597
16598 build_bii_list(true);
16599 char ps1[6],ps2[6],ps3[6];
16600 char info1[6],info2[6],info3[6];
16601 char shopname[32];
16602 char caption[40];
16603
16604 sprintf(caption,"Shop Data %d",index);
16605 editshop_dlg[0].dp = caption;
16606 editshop_dlg[0].dp2=get_zc_font(font_lfont);
16607
16608 sprintf(ps1,"%d",QMisc.shop[index].price[0]);
16609 sprintf(ps2,"%d",QMisc.shop[index].price[1]);
16610 sprintf(ps3,"%d",QMisc.shop[index].price[2]);
16611
16612 sprintf(info1,"%d",QMisc.shop[index].str[0]);
16613 sprintf(info2,"%d",QMisc.shop[index].str[1]);
16614 sprintf(info3,"%d",QMisc.shop[index].str[2]);
16615
16616 sprintf(shopname,"%s",QMisc.shop[index].name);
16617 editshop_dlg[8].dp = ps1;
16618 editshop_dlg[10].dp = ps2;
16619 editshop_dlg[12].dp = ps3;
16620 editshop_dlg[15].dp = shopname;
16621
16622 editshop_dlg[21].dp = info1;
16623 editshop_dlg[22].dp = info2;
16624 editshop_dlg[23].dp = info3;
16625
16626 ListData item_list(itemlist_num, &a4fonts[font_lfont_l]);
16627
16628 editshop_dlg[9].dp = (void *) &item_list;
16629 editshop_dlg[11].dp = (void *) &item_list;
16630 editshop_dlg[13].dp = (void *) &item_list;
16631
16632 for(int32_t i=0; i<3; ++i)
16633 {
16634 if(QMisc.shop[index].hasitem[i])
16635 {
16636 for(int32_t j=0; j<bii_cnt; j++)
16637 {
16638 if(bii[j].i == QMisc.shop[index].item[i])
16639 {
16640 editshop_dlg[9+(i<<1)].d1 = j;
16641 }
16642 }
16643 }
16644 else
16645 {
16646 editshop_dlg[9+(i<<1)].d1 = -2;
16647 }
16648 }
16649
16650 large_dialog(editshop_dlg);
16651
16652 int32_t ret = do_zqdialog(editshop_dlg,-1);
16653
16654 if(ret==16)
16655 {
16656 saved=false;
16657 QMisc.shop[index].price[0] = vbound(atoi(ps1), 0, 65535);
16658 QMisc.shop[index].price[1] = vbound(atoi(ps2), 0, 65535);
16659 QMisc.shop[index].price[2] = vbound(atoi(ps3), 0, 65535);
16660
16661 QMisc.shop[index].str[0] = vbound(atoi(info1), 0, 65535);
16662 QMisc.shop[index].str[1] = vbound(atoi(info2), 0, 65535);
16663 QMisc.shop[index].str[2] = vbound(atoi(info3), 0, 65535);
16664
16665 snprintf(QMisc.shop[index].name, 32, "%s",shopname);
16666
16667 for(int32_t i=0; i<3; ++i)
16668 {
16669 if(bii[editshop_dlg[9+(i<<1)].d1].i == -2)
16670 {
16671 QMisc.shop[index].hasitem[i] = 0;
16672 QMisc.shop[index].item[i] = 0;
16673 QMisc.shop[index].price[i] = 0;
16674 }
16675 else
16676 {
16677 QMisc.shop[index].hasitem[i] = 1;
16678 QMisc.shop[index].item[i] = bii[editshop_dlg[9+(i<<1)].d1].i;
16679 }
16680 }
16681
16682 //filter all the 0 items to the end (yeah, bubble sort; sue me)
16683 word swaptmp;
16684
16685 for(int32_t j=0; j<3-1; j++)
16686 {
16687 for(int32_t k=0; k<2-j; k++)
16688 {
16689 if(QMisc.shop[index].hasitem[k]==0)
16690 {
16691 swaptmp = QMisc.shop[index].item[k];
16692 QMisc.shop[index].item[k] = QMisc.shop[index].item[k+1];
16693 QMisc.shop[index].item[k+1] = swaptmp;
16694 swaptmp = QMisc.shop[index].price[k];
16695 QMisc.shop[index].price[k] = QMisc.shop[index].price[k+1];
16696 QMisc.shop[index].price[k+1] = swaptmp;
16697 swaptmp = QMisc.shop[index].hasitem[k];
16698 QMisc.shop[index].hasitem[k] = QMisc.shop[index].item[k+1];
16699 QMisc.shop[index].hasitem[k+1] = swaptmp;
16700 }
16701 }
16702 }
16703 }
16704 }
16705
16706 int32_t onShopTypes()
16707 {
16708 shop_list_size = 256;
16709
16710 int32_t index = select_data("Shop Types",0,shoplist,"Edit","Done",get_zc_font(font_lfont));
16711
16712 while(index!=-1)
16713 {
16714 EditShopType(index);
16715 index = select_data("Shop Types",index,shoplist,"Edit","Done",get_zc_font(font_lfont));
16716 }
16717
16718 return D_O_K;
16719 }
16720
16721 void call_bottle_dlg(int32_t index);
16722 int32_t onBottleTypes()
16723 {
16724 bottle_list_size = 64;
16725 int32_t index = 0;
16726
16727 while(index > -1)
16728 {
16729 index = select_data("Bottle Types", index, bottlelist, "Edit", "Done", get_zc_font(font_lfont));
16730 if(index > -1)
16731 call_bottle_dlg(index);
16732 }
16733
16734 return D_O_K;
16735 }
16736
16737 void call_bottleshop_dlg(int32_t index);
16738 int32_t onBottleShopTypes()
16739 {
16740 bottleshop_list_size = 256;
16741 int32_t index = 0;
16742
16743 while(index > -1)
16744 {
16745 index = select_data("Bottle Shop Types", index, bottleshoplist, "Edit", "Done", get_zc_font(font_lfont));
16746 if(index > -1)
16747 call_bottleshop_dlg(index);
16748 }
16749
16750 return D_O_K;
16751 }
16752
16753
16754 static char item_drop_set_str_buf[70];
16755 int32_t item_drop_set_list_size=MAXITEMDROPSETS;
16756
16757 const char *itemdropsetlist(int32_t index, int32_t *list_size)
16758 {
16759 if(index>=0)
16760 {
16761 bound(index,0,item_drop_set_list_size-1);
16762 sprintf(item_drop_set_str_buf,"%3d: %s",index,item_drop_sets[index].name);
16763 return item_drop_set_str_buf;
16764 }
16765
16766 *list_size=item_drop_set_list_size;
16767 return NULL;
16768 }
16769
16770 int32_t d_itemdropedit_proc(int32_t msg,DIALOG *d,int32_t c);
16771
16772 static int32_t edititemdropset_1_list[] =
16773 {
16774 // dialog control number
16775 10, 11, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,24,25,26,27,28, -1
16776 };
16777
16778 static int32_t edititemdropset_2_list[] =
16779 {
16780 // dialog control number
16781 12, 13, 29, 30, 31, 32, 33,34,35,36,37,38,39,40,41,42,43, -1
16782 };
16783
16784 static TABPANEL edititemdropset_tabs[] =
16785 {
16786 // (text)
16787 { (char *)" Page 1 ", D_SELECTED, edititemdropset_1_list, 0, NULL },
16788 { (char *)" Page 2 ", 0, edititemdropset_2_list, 0, NULL },
16789 { NULL, 0, NULL, 0, NULL }
16790 };
16791
16792 static DIALOG edititemdropset_dlg[] =
16793 {
16794 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
16795 12 { jwin_win_proc, 0, 0, 320, 240, vc(14), vc(1), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
16796 12 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
16797
16798 // 2
16799 12 { jwin_button_proc, 89, 213, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
16800 12 { jwin_button_proc, 169, 213, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
16801
16802 // 4
16803 12 { jwin_text_proc, 9, 29, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Name:", NULL, NULL },
16804 12 { jwin_edit_proc, 39, 25, 275, 16, vc(12), vc(1), 0, 0, 32, 0, NULL, NULL, NULL },
16805 12 { jwin_text_proc, 9, 47, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Nothing Chance:", NULL, NULL },
16806 12 { d_itemdropedit_proc, 84, 43, 26, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
16807
16808 12 { jwin_tab_proc, 4, 65, 312, 143, vc(0), vc(15), 0, 0, 0, 0, (void *) edititemdropset_tabs, NULL, (void *)edititemdropset_dlg },
16809 12 { jwin_text_proc, 114, 43+4, 26, 16, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
16810 // 10
16811 12 { jwin_text_proc, 10, 87, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Chance:", NULL, NULL },
16812 12 { jwin_text_proc, 56, 87, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Item:", NULL, NULL },
16813 12 { jwin_text_proc, 10, 87, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Chance:", NULL, NULL },
16814 12 { jwin_text_proc, 56, 87, 88, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Item:", NULL, NULL },
16815
16816 // 14
16817 12 { d_itemdropedit_proc, 9, 96, 26, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
16818 12 { d_idroplist_proc, 55, 96, 233, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
16819 12 { jwin_text_proc, 37, 96+4, 26, 16, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
16820 12 { d_itemdropedit_proc, 9, 118, 26, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
16821 12 { d_idroplist_proc, 55, 118, 233, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
16822 12 { jwin_text_proc, 37, 118+4, 26, 16, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
16823 12 { d_itemdropedit_proc, 9, 140, 26, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
16824 12 { d_idroplist_proc, 55, 140, 233, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
16825 12 { jwin_text_proc, 37, 140+4, 26, 16, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
16826 12 { d_itemdropedit_proc, 9, 162, 26, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
16827 12 { d_idroplist_proc, 55, 162, 233, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
16828 12 { jwin_text_proc, 37, 162+4, 26, 16, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
16829 12 { d_itemdropedit_proc, 9, 184, 26, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
16830 12 { d_idroplist_proc, 55, 184, 233, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
16831 12 { jwin_text_proc, 37, 184+4, 26, 16, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
16832 // 29
16833 12 { d_itemdropedit_proc, 9, 96, 26, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
16834 12 { d_idroplist_proc, 55, 96, 233, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
16835 12 { jwin_text_proc, 37, 96+4, 26, 16, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
16836 12 { d_itemdropedit_proc, 9, 118, 26, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
16837 12 { d_idroplist_proc, 55, 118, 233, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
16838 12 { jwin_text_proc, 37, 118+4, 26, 16, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
16839 12 { d_itemdropedit_proc, 9, 140, 26, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
16840 12 { d_idroplist_proc, 55, 140, 233, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
16841 12 { jwin_text_proc, 37, 140+4, 26, 16, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
16842 12 { d_itemdropedit_proc, 9, 162, 26, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
16843 12 { d_idroplist_proc, 55, 162, 233, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
16844 12 { jwin_text_proc, 37, 162+4, 26, 16, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
16845 12 { d_itemdropedit_proc, 9, 184, 26, 16, vc(12), vc(1), 0, 0, 5, 0, NULL, NULL, NULL },
16846 12 { d_idroplist_proc, 55, 184, 233, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
16847 12 { jwin_text_proc, 39, 184+4, 26, 16, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
16848 12 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
16849 };
16850
16851 int32_t d_itemdropedit_proc(int32_t msg,DIALOG *d,int32_t c)
16852 {
16853 int32_t ret = jwin_edit_proc(msg,d,c);
16854
16855 if(msg==MSG_DRAW)
16856 {
16857 int32_t t = atoi((char*)edititemdropset_dlg[7].dp);
16858
16859 for(int32_t i=0; i<10; ++i)
16860 {
16861 t += atoi((char*)edititemdropset_dlg[14+(i*3)].dp);
16862 }
16863
16864 {
16865 int32_t t2 = (int32_t)(100*atoi((char*)edititemdropset_dlg[7].dp) / zc_max(t,1));
16866 sprintf((char*)edititemdropset_dlg[9].dp,"%d%%%s",t2, t2 <= 11 ? " ":"");
16867 object_message(&edititemdropset_dlg[9],MSG_DRAW,c);
16868 }
16869
16870 for(int32_t i=0; i<10; ++i)
16871 {
16872 int32_t t2 = (int32_t)(100*atoi((char*)edititemdropset_dlg[14+(i*3)].dp) / zc_max(t,1));
16873 sprintf((char*)edititemdropset_dlg[16+(i*3)].dp,"%d%%%s",t2, t2 <= 11 ? " ":"");
16874 object_message(&edititemdropset_dlg[16+(i*3)],MSG_DRAW,c);
16875 }
16876
16877 }
16878
16879 return ret;
16880 }
16881
16882 void EditItemDropSet(int32_t index)
16883 {
16884 build_bii_list(true);
16885 char chance[11][10];
16886 char itemdropsetname[64];
16887 char caption[40];
16888 char percent_str[11][5];
16889
16890 sprintf(caption,"Item Drop Set Data %d",index);
16891 edititemdropset_dlg[0].dp = caption;
16892 edititemdropset_dlg[0].dp2=get_zc_font(font_lfont);
16893
16894 sprintf(itemdropsetname,"%s",item_drop_sets[index].name);
16895 edititemdropset_dlg[5].dp = itemdropsetname;
16896
16897 sprintf(chance[0],"%d",item_drop_sets[index].chance[0]);
16898 edititemdropset_dlg[7].dp = chance[0];
16899
16900 ListData item_list(itemlist_num, &a4fonts[font_lfont_l]);
16901 sprintf(percent_str[0]," ");
16902 edititemdropset_dlg[9].dp = percent_str[0];
16903
16904 for(int32_t i=0; i<10; ++i)
16905 {
16906 sprintf(chance[i+1],"%d",item_drop_sets[index].chance[i+1]);
16907 edititemdropset_dlg[14+(i*3)].dp = chance[i+1];
16908 edititemdropset_dlg[15+(i*3)].dp = (void *) &item_list;
16909 sprintf(percent_str[i+1]," ");
16910 edititemdropset_dlg[16+(i*3)].dp = percent_str[i+1];
16911
16912 if(item_drop_sets[index].chance[i+1]==0)
16913 {
16914 edititemdropset_dlg[15+(i*3)].d1 = -2;
16915 }
16916 else
16917 {
16918 for(int32_t j=0; j<bii_cnt; j++)
16919 {
16920 if(bii[j].i == item_drop_sets[index].item[i])
16921 {
16922 edititemdropset_dlg[15+(i*3)].d1 = j;
16923 }
16924 }
16925 }
16926 }
16927
16928 large_dialog(edititemdropset_dlg);
16929
16930 int32_t ret = do_zqdialog(edititemdropset_dlg,-1);
16931
16932 if(ret==2)
16933 {
16934 saved=false;
16935
16936 sprintf(item_drop_sets[index].name,"%s",itemdropsetname);
16937
16938 item_drop_sets[index].chance[0]=atoi(chance[0]);
16939
16940 for(int32_t i=0; i<10; ++i)
16941 {
16942 item_drop_sets[index].chance[i+1]=atoi(chance[i+1]);
16943
16944 if(bii[edititemdropset_dlg[15+(i*3)].d1].i == -2)
16945 {
16946 item_drop_sets[index].chance[i+1]=0;
16947 }
16948 else
16949 {
16950 item_drop_sets[index].item[i] = bii[edititemdropset_dlg[15+(i*3)].d1].i;
16951 }
16952
16953 if(item_drop_sets[index].chance[i+1]==0)
16954 {
16955 item_drop_sets[index].item[i] = 0;
16956 }
16957 }
16958 }
16959 }
16960
16961 9 int32_t count_item_drop_sets()
16962 {
16963 9 int32_t count=0;
16964 9 bool found=false;
16965
16966
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2195 times.
2195 for(count=255; (count>0); --count)
16967 {
16968
2/2
✓ Branch 0 taken 2186 times.
✓ Branch 1 taken 24056 times.
26242 for(int32_t i=0; (i<11); ++i)
16969 {
16970
2/2
✓ Branch 0 taken 24047 times.
✓ Branch 1 taken 9 times.
24056 if(item_drop_sets[count].chance[i]!=0)
16971 {
16972 9 found=true;
16973 9 break;
16974 }
16975 24047 }
16976
16977
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2186 times.
2195 if(found)
16978 {
16979 9 break;
16980 }
16981 2186 }
16982
16983 9 return count+1;
16984 }
16985
16986 int32_t onItemDropSets()
16987 {
16988 item_drop_set_list_size = MAXITEMDROPSETS;
16989
16990 int32_t index = select_data("Item Drop Sets",0,itemdropsetlist,"Edit","Done",get_zc_font(font_lfont));
16991
16992 while(index!=-1)
16993 {
16994 EditItemDropSet(index);
16995 index = select_data("Item Drop Sets",index,itemdropsetlist,"Edit","Done",get_zc_font(font_lfont));
16996 }
16997
16998 return D_O_K;
16999 }
17000
17001 int32_t curr_ring = 0;
17002
17003 void EditWarpRingScr(int32_t ring,int32_t index)
17004 {
17005 char caption[40],buf[10];
17006 restore_mouse();
17007
17008 sprintf(caption,"Ring %d Warp %d",ring,index+1);
17009 warpring_warp_dlg[0].dp = (void *)caption;
17010 warpring_warp_dlg[0].dp2=get_zc_font(font_lfont);
17011
17012 sprintf(buf,"%02X",QMisc.warp[ring].scr[index]);
17013 warpring_warp_dlg[3].d1 = QMisc.warp[ring].dmap[index];
17014 warpring_warp_dlg[4].dp = buf;
17015 warpring_warp_dlg[8].dp = buf;
17016 warpring_warp_dlg[8].dp3 = &warpring_warp_dlg[3].d1;
17017
17018 vector<DIALOG*> dlgs;
17019 dlgs.push_back(&warpring_warp_dlg[3]);
17020 dlgs.push_back(&warpring_warp_dlg[4]);
17021 warpring_warp_dlg[8].dp2 = &dlgs;
17022
17023 dmap_list_size=MAXDMAPS;
17024 dmap_list_zero=true;
17025
17026 large_dialog(warpring_warp_dlg);
17027
17028 int32_t ret=do_zqdialog(warpring_warp_dlg,-1);
17029
17030 if(ret==5 || ret==6)
17031 {
17032 saved=false;
17033 QMisc.warp[ring].dmap[index] = warpring_warp_dlg[3].d1;
17034 QMisc.warp[ring].scr[index] = zc_xtoi(buf);
17035 }
17036
17037 if(ret==6)
17038 {
17039 Map.dowarp2(ring,index);
17040 refresh(rALL);
17041 }
17042 }
17043
17044 int32_t d_warplist_proc(int32_t msg,DIALOG *d,int32_t c)
17045 {
17046 if(msg==MSG_DRAW)
17047 {
17048 int32_t *xy = (int32_t*)(d->dp3);
17049 int32_t ring = curr_ring;
17050 int32_t dmap = QMisc.warp[ring].dmap[d->d1];
17051 float temp_scale = 1.5;
17052
17053 drawdmap(dmap);
17054
17055 if(xy[0]||xy[1])
17056 {
17057 int32_t x = d->x+int32_t((xy[0]-2)*temp_scale);
17058 int32_t y = d->y+int32_t((xy[1]-2)*temp_scale);
17059 int32_t w = 84;
17060 int32_t h = 52;
17061 jwin_draw_frame(screen,x,y,w,h,FR_DEEP);
17062 drawdmap_screen(x+2,y+2,w-4,h-4,dmap);
17063 }
17064
17065 if(xy[2]||xy[3])
17066 {
17067 textprintf_ex(screen,font,d->x+int32_t(xy[2]*temp_scale),d->y+int32_t(xy[3]*temp_scale),jwin_pal[jcBOXFG],jwin_pal[jcBOX],"Map: %d ",DMaps[dmap].map+1);
17068 }
17069
17070 if(xy[4]||xy[5])
17071 {
17072 textprintf_ex(screen,font,d->x+int32_t(xy[4]*temp_scale),d->y+int32_t(xy[5]*temp_scale),jwin_pal[jcBOXFG],jwin_pal[jcBOX],"Level:%2d ",DMaps[dmap].level);
17073 }
17074
17075 if(xy[6]||xy[7])
17076 {
17077 textprintf_ex(screen,font,d->x+int32_t(xy[6]*temp_scale),d->y+int32_t(xy[7]*temp_scale),jwin_pal[jcBOXFG],jwin_pal[jcBOX],"Scr: 0x%02X ",QMisc.warp[ring].scr[d->d1]);
17078 }
17079 }
17080
17081 return jwin_list_proc(msg,d,c);
17082 }
17083
17084 int32_t d_wclist_proc(int32_t msg,DIALOG *d,int32_t c)
17085 {
17086 int32_t d1 = d->d1;
17087 int32_t ret = jwin_droplist_proc(msg,d,c);
17088 QMisc.warp[curr_ring].size=d->d1+3;
17089
17090 if(d->d1 != d1)
17091 return D_CLOSE;
17092
17093 return ret;
17094 }
17095
17096 const char *wclist(int32_t index, int32_t *list_size)
17097 {
17098 static char buf[2];
17099
17100 if(index>=0)
17101 {
17102 if(index>6)
17103 index=6;
17104
17105 sprintf(buf,"%d",index+3);
17106 return buf;
17107 }
17108
17109 *list_size=7;
17110 return NULL;
17111 }
17112
17113 //int32_t warpringdmapxy[8] = {160,116,160,90,160,102,160,154};
17114 int32_t warpringdmapxy[8] = {80,26,80,0,80,12,80,78};
17115
17116 12 static ListData number_list(numberlist, &font);
17117 12 static ListData wc_list(wclist, &font);
17118
17119 static DIALOG warpring_dlg[] =
17120 {
17121 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
17122 12 { jwin_win_proc, 0, 0, 193, 166, vc(14), vc(1), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
17123 12 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
17124 12 { jwin_text_proc, 16, 33, 48, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Count:", NULL, NULL },
17125 12 { d_wclist_proc, 72, 29, 48, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 1, 0, (void *) &wc_list, NULL, NULL },
17126 // 4
17127 12 { d_warplist_proc, 16, 50, 65, 71, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, D_EXIT, 0, 0, (void *) &number_list, NULL, warpringdmapxy },
17128 12 { jwin_button_proc, 26, 140, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Edit", NULL, NULL },
17129 12 { jwin_button_proc, 106, 140, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Done", NULL, NULL },
17130 12 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onHelp, NULL, NULL },
17131 12 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
17132 };
17133
17134 int32_t select_warp()
17135 {
17136 QMisc.warp[curr_ring].size = vbound(QMisc.warp[curr_ring].size,3,9);
17137 number_list_zero = false;
17138
17139 int32_t ret=4;
17140
17141 large_dialog(warpring_dlg);
17142
17143 do
17144 {
17145 number_list_size = QMisc.warp[curr_ring].size;
17146 warpring_dlg[3].d1 = QMisc.warp[curr_ring].size-3;
17147 ret = do_zqdialog(warpring_dlg,ret);
17148 }
17149 while(ret==3);
17150
17151 if(ret==6 || ret==0)
17152 {
17153 return -1;
17154 }
17155
17156 return warpring_dlg[4].d1;
17157 }
17158
17159 void EditWarpRing(int32_t ring)
17160 {
17161 char buf[40];
17162 sprintf(buf,"Ring %d Warps",ring);
17163 warpring_dlg[0].dp = buf;
17164 warpring_dlg[0].dp2 = get_zc_font(font_lfont);
17165 curr_ring = ring;
17166
17167 int32_t index = select_warp();
17168
17169 while(index!=-1)
17170 {
17171 EditWarpRingScr(ring,index);
17172 index = select_warp();
17173 }
17174 }
17175
17176 int32_t onWarpRings()
17177 {
17178 number_list_size = 9;
17179 number_list_zero = true;
17180
17181 int32_t index = select_data("Warp Rings",0,numberlist,"Edit","Done",get_zc_font(font_lfont));
17182
17183 while(index!=-1)
17184 {
17185 EditWarpRing(index);
17186 number_list_size = 9;
17187 number_list_zero = true;
17188 index = select_data("Warp Rings",index,numberlist,"Edit","Done",get_zc_font(font_lfont));
17189 }
17190
17191 return D_O_K;
17192 }
17193
17194 const char *enemy_viewer(int32_t index, int32_t *list_size)
17195 {
17196 if(index<0)
17197 {
17198 *list_size=10;
17199
17200 return NULL;
17201 }
17202
17203 int32_t guy=Map.CurrScr()->enemy[index];
17204
17205 if (guy == 0) return "(None)";
17206 return guy>=eSTART ? guy_string[guy] : (char *) "(Guy - Do Not Use!)";
17207 }
17208
17209 enemy_struct bie[eMAXGUYS];
17210 enemy_struct ce[100];
17211 int32_t enemy_type=0,bie_cnt=-1,ce_cnt;
17212
17213 enemy_struct big[zqMAXGUYS];
17214 enemy_struct cg[100];
17215 int32_t guy_type=0,big_cnt=-1,cg_cnt;
17216
17217 //Uses old_max_guys[] in zq_misc.cpp to define what are visible if bool hide is set true. -Z
17218 void build_bie_list(bool hide)
17219 {
17220 bie[0].s = (char *)"(None)";
17221 bie[0].i = 0;
17222 bie_cnt=1;
17223
17224 for(int32_t i=1; i<eMAXGUYS; i++)
17225 {
17226 if (i < eSTART) continue; // ignore guys - enemies only!
17227
17228 if(i >= OLDMAXGUYS || old_guy_string[i][strlen(old_guy_string[i])-1]!=' ' || !hide)
17229 {
17230 bie[bie_cnt].s = (char *)guy_string[i];
17231 bie[bie_cnt].i = i;
17232 ++bie_cnt;
17233 }
17234 }
17235
17236 for(int32_t i=1; i<bie_cnt-1; i++) //Start at 1 so '(None)' isn't alphabetized!
17237 {
17238 for(int32_t j=i+1; j<bie_cnt; j++)
17239 {
17240 if(strcmp(bie[i].s,bie[j].s)>0)
17241 {
17242 zc_swap(bie[i],bie[j]);
17243 }
17244 }
17245 }
17246 }
17247
17248 int32_t efrontfacingtile(int32_t id)
17249 {
17250 int32_t anim = get_qr(qr_NEWENEMYTILES)?guysbuf[id].e_anim:guysbuf[id].anim;
17251 int32_t usetile = 0;
17252
17253 switch(anim)
17254 {
17255
17256 case aNONE: break;
17257 case aAQUA:
17258 if(!(get_qr(qr_NEWENEMYTILES) && guysbuf[id].attributes[0]))
17259 break;
17260
17261 case aWALLM:
17262 case aGHOMA:
17263 usetile=1;
17264 break;
17265
17266 //Fallthrough
17267 case a2FRM4DIR:
17268 case aWALK:
17269 usetile=2;
17270 break;
17271
17272 case aLEV:
17273 case a3FRM4DIR:
17274 usetile=3;
17275 break;
17276
17277 case aLANM:
17278 usetile = !(get_qr(qr_NEWENEMYTILES))?0:4;
17279 break;
17280
17281 case aNEWDONGO:
17282 case a4FRM8EYE:
17283 case aNEWWIZZ:
17284 case aARMOS4:
17285 case aNEWTEK:
17286 case aNEWWALLM:
17287 case a4FRM4DIRF:
17288 case a4FRM4DIR:
17289 case a4FRM8DIRF:
17290 case a4FRMPOS8DIR:
17291 case a4FRMPOS8DIRF:
17292 case a4FRMPOS4DIR:
17293 case a4FRMPOS4DIRF:
17294 usetile=4;
17295 break;
17296
17297 case aDONGO:
17298 usetile=6;
17299 break;
17300
17301 case aDONGOBS:
17302 usetile=24;
17303 break;
17304
17305 case aNEWLEV:
17306 usetile=40;
17307 break;
17308
17309 case aNEWZORA:
17310 if(guysbuf[id].family==eeZORA)
17311 usetile=44;
17312
17313 break;
17314
17315 case aGLEEOK:
17316 if(!get_qr(qr_NEWENEMYTILES))
17317 usetile = (guysbuf[id].s_tile - guysbuf[id].tile)+1;
17318 else
17319 usetile = (guysbuf[id].attributes[7]);
17320
17321 break;
17322 }
17323
17324 return zc_max(get_qr(qr_NEWENEMYTILES) ? -guysbuf[id].e_tile
17325 : -guysbuf[id].tile, usetile);
17326 }
17327
17328 int32_t onEnemies()
17329 {
17330 call_screenenemies_dialog();
17331 refresh(rALL);
17332 return D_O_K;
17333 }
17334
17335 char author[65],title[65],password[32];
17336
17337 int32_t d_showedit_proc(int32_t msg,DIALOG *d,int32_t c)
17338 {
17339 int32_t ret = jwin_edit_proc(msg,d,c);
17340
17341 if(msg==MSG_DRAW)
17342 {
17343 (d+1)->proc(MSG_DRAW,d+1,0);
17344 }
17345
17346 return ret;
17347 }
17348
17349 int32_t onHeader()
17350 {
17351 call_header_dlg();
17352 return D_O_K;
17353 }
17354
17355 void call_cheats_dlg();
17356 int32_t onCheats()
17357 {
17358 call_cheats_dlg();
17359 return D_O_K;
17360 }
17361
17362 bool do_x_button(BITMAP *dest, int32_t x, int32_t y)
17363 {
17364 bool over=false;
17365
17366 while(gui_mouse_b())
17367 {
17368 custom_vsync();
17369
17370 if(isinRect(gui_mouse_x(),gui_mouse_y(),x,y,x+15,y+13))
17371 {
17372 if(!over)
17373 {
17374 draw_x_button(dest, x, y, D_SELECTED);
17375 over=true;
17376 }
17377 }
17378 else
17379 {
17380 if(over)
17381 {
17382 draw_x_button(dest, x, y, 0);
17383 over=false;
17384 }
17385 }
17386 }
17387
17388 return over;
17389 }
17390
17391 bool do_question_button(BITMAP *dest, int32_t x, int32_t y)
17392 {
17393 bool over=false;
17394
17395 while(gui_mouse_b())
17396 {
17397 custom_vsync();
17398
17399 if(isinRect(gui_mouse_x(),gui_mouse_y(),x,y,x+15,y+13))
17400 {
17401 if(!over)
17402 {
17403 draw_question_button(dest, x, y, D_SELECTED);
17404 over=true;
17405 }
17406 }
17407 else
17408 {
17409 if(over)
17410 {
17411 draw_question_button(dest, x, y, 0);
17412 over=false;
17413 }
17414 }
17415 }
17416
17417 return over;
17418 }
17419
17420
17421 int32_t d_dummy_proc(int32_t,DIALOG *,int32_t)
17422 {
17423 return D_O_K;
17424 }
17425
17426 int32_t d_maptile_proc(int32_t msg, DIALOG *d, int32_t)
17427 {
17428 switch(msg)
17429 {
17430 case MSG_CLICK:
17431 if(select_tile(d->d1,d->d2,1,d->fg,true, 0, true))
17432 return D_REDRAW;
17433
17434 case MSG_DRAW:
17435 {
17436 int32_t dw = d->w;
17437 int32_t dh = d->h;
17438
17439 if(d->dp2==(void*)1)
17440 {
17441 dw /= 2;
17442 dh /= 2;
17443 }
17444
17445 BITMAP *buf = create_bitmap_ex(8,dw,dh);
17446
17447 if(buf)
17448 {
17449 clear_bitmap(buf);
17450
17451 for(int32_t y=0; y<dh; y+=16)
17452 for(int32_t x=0; x<dw; x+=16)
17453 {
17454 if(d->d1)
17455 puttile16(buf,d->d1+(y>>4)*20+(x>>4),x,y,d->fg,0);
17456 }
17457
17458 if(d->dp2==(void*)1)
17459 stretch_blit(buf,screen,0,0,dw,dh,d->x-1,d->y-1,dw*2,dh*2);
17460 else
17461 blit(buf,screen,0,0,d->x,d->y,dw,dh);
17462
17463 destroy_bitmap(buf);
17464 }
17465 }
17466 }
17467
17468 return D_O_K;
17469 }
17470
17471 static int32_t last_combo=0;
17472 static int32_t last_cset=0;
17473
3/4
✓ Branch 0 taken 98304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98292 times.
✓ Branch 3 taken 12 times.
98304 static combo_alias temp_aliases[MAXCOMBOALIASES];
17474
17475 static char comboa_str_buf[32];
17476
17477 int32_t d_comboalist_proc(int32_t msg,DIALOG *d,int32_t c)
17478 {
17479 int32_t d1 = d->d1;
17480 int32_t ret = jwin_droplist_proc(msg,d,c);
17481 comboa_cnt = d->d1;
17482
17483 if(d1!=d->d1)
17484 {
17485 set_comboaradio(temp_aliases[comboa_cnt].layermask);
17486 return D_REDRAW;
17487 }
17488
17489 return ret;
17490 }
17491
17492 const char *comboalist(int32_t index, int32_t *list_size)
17493 {
17494 if(index>=0)
17495 {
17496 bound(index,0,MAXCOMBOALIASES-1);
17497 sprintf(comboa_str_buf,"%d",index);
17498 return comboa_str_buf;
17499 }
17500
17501 *list_size=MAXCOMBOALIASES;
17502 return NULL;
17503 }
17504
17505 extern int32_t scheme[jcMAX];
17506
17507 int32_t d_comboa_proc(int32_t msg,DIALOG *d,int32_t c)
17508 {
17509 //these are here to bypass compiler warnings about unused arguments
17510 c=c;
17511
17512 combo_alias *combo;
17513 combo = &temp_aliases[comboa_cnt];
17514 int32_t position;
17515 int32_t cur_layer, temp_layer;
17516 int32_t lay_count=0;
17517 int32_t size = 2;
17518
17519 int32_t cx1=(gui_mouse_x()-d->x-(120-(combo->width*8)));
17520 int32_t cy1=(gui_mouse_y()-d->y-(80-(combo->height*8)));
17521 int32_t cx=cx1/(16*size);
17522 int32_t cy=cy1/(16*size);
17523
17524 int32_t co,cs;
17525
17526
17527 switch(msg)
17528 {
17529 case MSG_CLICK:
17530 if((cx>combo->width)||(cx1<0))
17531 return D_O_K;
17532
17533 if((cy>combo->height)||(cy1<0))
17534 return D_O_K;
17535
17536 for(int32_t j=0; j<layer_cnt; j++)
17537 {
17538 if(combo->layermask&(1<<j))
17539 lay_count++;
17540 }
17541
17542 position=(lay_count)*(combo->width+1)*(combo->height+1);
17543 position+=(cy*(combo->width+1))+cx;
17544
17545 if(key[KEY_LSHIFT]||key[KEY_RSHIFT])
17546 {
17547 combo->combos[position] = 0;
17548 combo->csets[position] = 0;
17549
17550 while(gui_mouse_b())
17551 {
17552 /* do nothing */
17553 rest(1);
17554 }
17555
17556 return D_REDRAW;
17557 }
17558
17559 co=combo->combos[position];
17560 cs=combo->csets[position];
17561
17562 if((co==0)||(key[KEY_ZC_LCONTROL]))
17563 {
17564 co=last_combo;
17565 cs=last_cset;
17566 }
17567
17568 if((select_combo_2(co,cs)))
17569 {
17570 last_combo = co;
17571 last_cset = cs;
17572
17573 combo->combos[position]=co;
17574 combo->csets[position]=cs;
17575 }
17576
17577 return D_REDRAW;
17578 break;
17579
17580 case MSG_DRAW:
17581 BITMAP *buf = create_bitmap_ex(8,d->w,d->h);
17582
17583 if(buf)
17584 {
17585 clear_bitmap(buf);
17586
17587 for(int32_t z=0; z<=comboa_lmasktotal(combo->layermask); z++)
17588 {
17589 int32_t k=0;
17590 cur_layer=0;
17591 temp_layer=combo->layermask;
17592
17593 while((temp_layer!=0)&&(k<z))
17594 {
17595 if(temp_layer&1)
17596 {
17597 k++;
17598 }
17599
17600 cur_layer++;
17601 temp_layer = temp_layer>>1;
17602 }
17603
17604 for(int32_t y=0; (y<d->h)&&((y/16)<=combo->height); y+=16)
17605 {
17606 for(int32_t x=0; (x<d->w)&&((x/16)<=combo->width); x+=16)
17607 {
17608 int32_t cpos = (z*(combo->width+1)*(combo->height+1))+(((y/16)*(combo->width+1))+(x/16));
17609
17610 if(combo->combos[cpos])
17611 {
17612 if(!((d-1)->flags&D_SELECTED)||(cur_layer==layer_cnt))
17613 {
17614 if(z==0)
17615 {
17616 puttile16(buf,combobuf[combo->combos[cpos]].tile,x,y,combo->csets[cpos],combobuf[combo->combos[cpos]].flip);
17617 }
17618 else
17619 {
17620 overtile16(buf,combobuf[combo->combos[cpos]].tile,x,y,combo->csets[cpos],combobuf[combo->combos[cpos]].flip);
17621 }
17622 }
17623 }
17624 }
17625 }
17626 }
17627
17628 rectfill(screen, d->x-2,d->y-2,d->x+256+2,d->y+176+2,jwin_pal[jcBOX]);
17629 int32_t dx = 120-(combo->width*8)+d->x;
17630 int32_t dy = 80-(combo->height*8)+d->y;
17631 stretch_blit(buf,screen,0,0,(combo->width+1)*16,(combo->height+1)*16,dx,dy,(combo->width+1)*16*size,(combo->height+1)*16*size);
17632 //blit(buf,screen,0,0,120-(combo->width*8)+d->x,80-(combo->height*8)+d->y,(combo->width+1)*16,(combo->height+1)*16);
17633 (d-11)->w = (combo->width+1)*16*size+2;
17634 (d-11)->h = (combo->height+1)*16*size+2;
17635 (d-11)->x = 120-(combo->width*8)+4*size+2+(d-14)->x;
17636 (d-11)->y = 80-(combo->height*8)+25*size+2+(d-14)->y;
17637 object_message((d-11),MSG_DRAW,0);
17638
17639 destroy_bitmap(buf);
17640 }
17641
17642 break;
17643 }
17644
17645 return D_O_K;
17646 }
17647
17648 void draw_combo_alias_thumbnail(BITMAP *dest, combo_alias const* combo, int32_t x, int32_t y, int32_t size)
17649 {
17650 if(!combo->combo)
17651 {
17652 int32_t cur_layer, temp_layer;
17653
17654 int32_t cw=combo->width+1;
17655 int32_t ch=combo->height+1;
17656 int32_t dw=cw<<4;
17657 int32_t dh=ch<<4;
17658 int32_t sw=16, sh=16, sx=0, sy=0;
17659
17660 if(cw<ch)
17661 {
17662 sw=((cw<<4)/ch);
17663 sx=((16-sw)>>1);
17664 }
17665 else
17666 {
17667 sh=((ch<<4)/cw);
17668 sy=((16-sh)>>1);
17669 }
17670
17671 BITMAP *buf = create_bitmap_ex(8,dw,dh);
17672 BITMAP *buf2 = create_bitmap_ex(8, 16*size, 16*size);
17673 clear_bitmap(buf);
17674 clear_bitmap(buf2);
17675
17676 if(buf&&(combo->width>0||combo->height>0||combo->combos[0]>0))
17677 {
17678 clear_bitmap(buf);
17679
17680 for(int32_t z=0; z<=comboa_lmasktotal(combo->layermask); z++)
17681 {
17682 int32_t k=0;
17683 cur_layer=0;
17684 temp_layer=combo->layermask;
17685
17686 while((temp_layer!=0)&&(k<z))
17687 {
17688 if(temp_layer&1)
17689 {
17690 k++;
17691 }
17692
17693 cur_layer++;
17694 temp_layer = temp_layer>>1;
17695 }
17696
17697 for(int32_t y2=0; (y2<dh)&&((y2>>4)<=combo->height); y2+=16)
17698 {
17699 for(int32_t x2=0; (x2<dw)&&((x2>>4)<=combo->width); x2+=16)
17700 {
17701 int32_t cpos = (z*(combo->width+1)*(combo->height+1))+(((y2/16)*(combo->width+1))+(x2/16));
17702
17703 if(combo->combos[cpos])
17704 {
17705 if(z==0)
17706 {
17707 puttile16(buf,combobuf[combo->combos[cpos]].tile,x2,y2,combo->csets[cpos],combobuf[combo->combos[cpos]].flip);
17708 }
17709 else
17710 {
17711 overtile16(buf,combobuf[combo->combos[cpos]].tile,x2,y2,combo->csets[cpos],combobuf[combo->combos[cpos]].flip);
17712 }
17713 }
17714 }
17715 }
17716 }
17717
17718 stretch_blit(buf, buf2, 0, 0, (cw*16), (ch*16), sx*size, sy*size, sw*size, sh*size);
17719 blit(buf2, dest, 0, 0, x, y, 16*size, 16*size);
17720 }
17721 else
17722 {
17723 rectfill(dest,x,y,x+16*size-1,y+16*size-1,0);
17724 rectfill(dest,x+3*size,y+3*size,x+12*size,y+12*size,vc(4));
17725 }
17726
17727 if(buf)
17728 destroy_bitmap(buf);
17729
17730 if(buf2)
17731 destroy_bitmap(buf2);
17732 }
17733 else
17734 {
17735 if(combobuf[combo->combo].tile>0)
17736 {
17737 rectfill(dest,x,y,x+16*size-1,y+16*size-1,0);
17738 put_combo(dest, x, y, combo->combo, combo->cset, 0, 0, size);
17739 }
17740 else
17741 {
17742 rectfill(dest,x,y,x+16*size-1,y+16*size-1,0);
17743 rectfill(dest,x+3*size,y+3*size,x+12*size,y+12*size,vc(4));
17744 }
17745 }
17746 }
17747
17748 int32_t d_comboat_proc(int32_t msg,DIALOG *d,int32_t)
17749 {
17750 switch(msg)
17751 {
17752 case MSG_CLICK:
17753 {
17754 int32_t c2;
17755 int32_t cs;
17756 c2=temp_aliases[comboa_cnt].combo;
17757 cs=temp_aliases[comboa_cnt].cset;
17758
17759 if(gui_mouse_b()&2) //right mouse button
17760 {
17761 if(c2==0&&cs==0&&!(gui_mouse_b()&1))
17762 {
17763 return D_O_K;
17764 }
17765
17766 temp_aliases[comboa_cnt].combo=0;
17767 temp_aliases[comboa_cnt].cset=0;
17768 }
17769
17770 if(gui_mouse_b()&1) //left mouse button
17771 {
17772 if(select_combo_2(c2, cs))
17773 {
17774 temp_aliases[comboa_cnt].combo=c2;
17775 temp_aliases[comboa_cnt].cset=cs;
17776 }
17777
17778 return D_REDRAW;
17779 }
17780 else
17781 {
17782 return D_REDRAWME;
17783 }
17784 }
17785 break;
17786
17787 case MSG_DRAW:
17788 draw_combo_alias_thumbnail(screen, &temp_aliases[comboa_cnt], d->x-1, d->y-1,2);
17789 break;
17790
17791 default:
17792 break;
17793 }
17794
17795 return D_O_K;
17796 }
17797
17798 int32_t d_comboa_radio_proc(int32_t msg,DIALOG *d,int32_t c);
17799
17800 static DIALOG orgcomboa_dlg[] =
17801 {
17802 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
17803 { jwin_win_proc, 0, 0, 200, 161, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Organize Combo Aliases", NULL, NULL },
17804 { jwin_button_proc, 27, 130, 61, 21, vc(14), vc(1), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
17805 { jwin_button_proc, 112, 130, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
17806
17807 { jwin_radio_proc, 10, 40, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void*) "Copy", NULL, NULL },
17808 { jwin_text_proc, 10, 50, 33, 9, 0, 0, 0, 0, 0, 0, (void *) "", NULL, NULL },
17809 // { jwin_radio_proc, 10, 50, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void*) "Move", NULL, NULL },
17810 { jwin_radio_proc, 10, 60, 33, 9, vc(14), vc(1), 0, 0, 0, 0, (void*) "Swap", NULL, NULL },
17811 /* 6 */ { jwin_edit_proc, 110, 35, 32, 16, vc(12), vc(1), 0, 0, 4, 0, NULL, NULL, NULL },
17812 { jwin_edit_proc, 110, 55, 32, 16, vc(12), vc(1), 0, 0, 4, 0, NULL, NULL, NULL },
17813 { jwin_text_proc, 60, 40, 80, 8, 0, 0, 0, 0, 0, 0, (void *) "Source", NULL, NULL },
17814 { jwin_text_proc, 60, 60, 80, 8, 0, 0, 0, 0, 0, 0, (void *) "Dest", NULL, NULL},
17815 { jwin_radio_proc, 10, 80, 60, 9, vc(14), vc(1), 0, 0, 0, 0, (void*) "Insert new (before source)", NULL, NULL },
17816 { jwin_radio_proc, 10, 100, 60, 9, vc(14), vc(1), 0, 0, 0, 0, (void*) "Delete source", NULL, NULL },
17817 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
17818 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
17819 };
17820
17821 static DIALOG newcomboa_dlg[] =
17822 {
17823 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
17824 { jwin_win_proc, 0, 0, 200, 161, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Combo Alias Properties", NULL, NULL },
17825 { jwin_button_proc, 27, 130, 61, 21, vc(14), vc(1), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
17826 { jwin_button_proc, 112, 130, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
17827 { jwin_text_proc, 24, 34, 80, 8, 0, 0, 0, 0, 0, 0, (void *) "Alias Width", NULL, NULL },
17828 { jwin_text_proc, 24, 52, 80, 8, 0, 0, 0, 0, 0, 0, (void *) "Alias Height", NULL, NULL },
17829 { jwin_text_proc, 24, 70, 100, 8, 0, 0, 0, 0, 0, 0, (void *) "Layers to Draw On:", NULL, NULL },
17830 { jwin_edit_proc, 104, 30, 28-6, 16, vc(12), vc(1), 0, 0, 2, 0, NULL, NULL, NULL },
17831 { jwin_edit_proc, 122, 48, 28-6, 16, vc(12), vc(1), 0, 0, 2, 0, NULL, NULL, NULL },
17832 { jwin_check_proc, 24, 86, 24, 9, vc(12), vc(1), 0, 0, 1, 0, (void *) "1", NULL, NULL },
17833 { jwin_check_proc, 50, 86, 24, 9, vc(12), vc(1), 0, 0, 1, 0, (void *) "2", NULL, NULL },
17834 { jwin_check_proc, 76, 86, 24, 9, vc(12), vc(1), 0, 0, 1, 0, (void *) "3", NULL, NULL },
17835 { jwin_check_proc, 102, 86, 24, 9, vc(12), vc(1), 0, 0, 1, 0, (void *) "4", NULL, NULL },
17836 { jwin_check_proc, 128, 86, 24, 9, vc(12), vc(1), 0, 0, 1, 0, (void *) "5", NULL, NULL },
17837 { jwin_check_proc, 154, 86, 24, 9, vc(12), vc(1), 0, 0, 1, 0, (void *) "6", NULL, NULL },
17838
17839
17840 // { jwin_text_proc, 24, 106, 80, 8, 0, 0, 0, 0, 0, 0, (void *) "Copy to :", NULL, NULL },
17841 //15
17842 // { jwin_edit_proc, 100, 100, 28-6, 16, vc(12), vc(1), 0, 0, 2, 0, NULL, NULL, NULL },
17843 // { jwin_check_proc, 84, 106, 24, 9, vc(12), vc(1), 0, 0, 1, 0, (void *) "", NULL, NULL },
17844
17845 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
17846 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
17847 };
17848
17849 bool swapComboAlias(int32_t source, int32_t dest)
17850 {
17851 if(source==dest)
17852 return false;
17853 zc_swap(temp_aliases[source],temp_aliases[dest]);
17854 return true;
17855 }
17856
17857
17858 bool copyComboAlias(int32_t source, int32_t dest)
17859 {
17860 if(source == dest)
17861 return false;
17862 temp_aliases[dest] = temp_aliases[source];
17863 return true;
17864 }
17865
17866 int32_t getcurrentcomboalias();
17867
17868 int32_t onOrgComboAliases()
17869 {
17870 char cSrc[8];
17871 char cDest[8];
17872 sprintf(cSrc,"%d", getcurrentcomboalias());
17873 strcpy(cDest,cSrc);
17874 int32_t iSrc = 0;
17875 int32_t iDest = 0;
17876
17877 //sprintf(cSrc,"0");
17878 //sprintf(cDest,"0");
17879 orgcomboa_dlg[0].dp2=get_zc_font(font_lfont);
17880 orgcomboa_dlg[6].dp= cSrc;
17881 orgcomboa_dlg[7].dp= cDest;
17882 int32_t ret = 1;
17883 large_dialog(orgcomboa_dlg);
17884 do
17885 {
17886 iSrc = atoi((char*)orgcomboa_dlg[6].dp);
17887 iDest = atoi((char*)orgcomboa_dlg[7].dp);
17888 ret = do_zqdialog(orgcomboa_dlg,-1);
17889
17890 if(ret!=1) return ret;
17891
17892 if((atoi((char*) orgcomboa_dlg[6].dp))<0 || (atoi((char*) orgcomboa_dlg[6].dp)) > MAXCOMBOALIASES-1)
17893 {
17894 char buf[100];
17895 snprintf(buf, 100, "Invalid source (range 0-%d)", MAXCOMBOALIASES-1);
17896 buf[99]='\0';
17897 jwin_alert("Error",buf,NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
17898 ret = 1;
17899 }
17900
17901 // 10,11=ins, del
17902 if(orgcomboa_dlg[10].flags & D_SELECTED) //insert
17903 {
17904 for(int32_t j=MAXCOMBOALIASES-1; j>(atoi((char*) orgcomboa_dlg[6].dp)); --j)
17905 copyComboAlias(j-1,j);
17906 ret = -1;
17907 }
17908
17909 if(orgcomboa_dlg[11].flags & D_SELECTED) //delete
17910 {
17911 for(int32_t j=(atoi((char*) orgcomboa_dlg[6].dp)); j<MAXCOMBOALIASES-1; ++j)
17912 copyComboAlias(j+1,j);
17913 ret = -1;
17914 }
17915
17916 if((atoi((char*) orgcomboa_dlg[6].dp)) == (atoi((char*) orgcomboa_dlg[7].dp)))
17917 {
17918 jwin_alert("Error","Source and dest can't be the same.",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
17919 ret = 1;
17920 }
17921
17922 if((atoi((char*) orgcomboa_dlg[7].dp)) < 0 || (atoi((char*) orgcomboa_dlg[7].dp)) > MAXCOMBOALIASES-1)
17923 {
17924 char buf[100];
17925 snprintf(buf, 100, "Invalid dest (range 0-%d)", MAXCOMBOALIASES-1);
17926 buf[99]='\0';
17927
17928 jwin_alert("Error",buf,NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
17929 ret = 1;
17930 }
17931
17932 if(orgcomboa_dlg[3].flags & D_SELECTED) //copy
17933 {
17934 copyComboAlias((atoi((char*) orgcomboa_dlg[6].dp)),(atoi((char*) orgcomboa_dlg[7].dp)));
17935 ret = -1;
17936 }
17937
17938 if(orgcomboa_dlg[5].flags & D_SELECTED) //swap
17939 {
17940 swapComboAlias((atoi((char*) orgcomboa_dlg[6].dp)),(atoi((char*) orgcomboa_dlg[7].dp)));
17941 ret = -1;
17942 }
17943 }
17944 while(ret==1);
17945 return ret;
17946 }
17947
17948 int32_t onNewComboAlias()
17949 {
17950 combo_alias *combo;
17951 combo = &temp_aliases[comboa_cnt];
17952
17953 char cwidth[5];
17954 char cheight[5];
17955 // char cp[3];
17956
17957 word temp_combos[16*11*7];
17958 byte temp_csets[16*11*7];
17959 sprintf(cwidth, "%d", combo->width+1);
17960 sprintf(cheight, "%d", combo->height+1);
17961 int32_t old_count = (comboa_lmasktotal(combo->layermask)+1)*(combo->width+1)*(combo->height+1);
17962 int32_t old_width=combo->width;
17963 int32_t old_height=combo->height;
17964 int32_t oldlayer=combo->layermask;
17965
17966 for(int32_t i=0; i<old_count; i++)
17967 {
17968 temp_csets[i] = combo->csets[i];
17969 temp_combos[i] = combo->combos[i];
17970 }
17971
17972 newcomboa_dlg[0].dp2 = get_zc_font(font_lfont);
17973 newcomboa_dlg[6].dp = cwidth;
17974 newcomboa_dlg[7].dp = cheight;
17975 newcomboa_dlg[8].flags = (combo->layermask&1)? D_SELECTED : 0;
17976 newcomboa_dlg[9].flags = (combo->layermask&2)? D_SELECTED : 0;
17977 newcomboa_dlg[10].flags = (combo->layermask&4)? D_SELECTED : 0;
17978 newcomboa_dlg[11].flags = (combo->layermask&8)? D_SELECTED : 0;
17979 newcomboa_dlg[12].flags = (combo->layermask&16)? D_SELECTED : 0;
17980 newcomboa_dlg[13].flags = (combo->layermask&32)? D_SELECTED : 0;
17981
17982 large_dialog(newcomboa_dlg);
17983
17984 int32_t ret = do_zqdialog(newcomboa_dlg,-1);
17985
17986 if(ret==1)
17987 {
17988 combo->width = ((atoi(cwidth)-1)<16)?zc_max(0,(atoi(cwidth)-1)):15;
17989 combo->height = ((atoi(cheight)-1)<11)?zc_max(0,(atoi(cheight)-1)):10;
17990 combo->layermask=0;
17991 combo->layermask |= (newcomboa_dlg[8].flags&D_SELECTED)?1:0;
17992 combo->layermask |= (newcomboa_dlg[9].flags&D_SELECTED)?2:0;
17993 combo->layermask |= (newcomboa_dlg[10].flags&D_SELECTED)?4:0;
17994 combo->layermask |= (newcomboa_dlg[11].flags&D_SELECTED)?8:0;
17995 combo->layermask |= (newcomboa_dlg[12].flags&D_SELECTED)?16:0;
17996 combo->layermask |= (newcomboa_dlg[13].flags&D_SELECTED)?32:0;
17997
17998 int32_t new_count = (comboa_lmasktotal(combo->layermask)+1)*(combo->width+1)*(combo->height+1);
17999
18000 combo->combos.clear();
18001 combo->csets.clear();
18002
18003 int32_t j=1;
18004 int32_t old_size=(old_width+1)*(old_height+1);
18005 int32_t new_start[7] =
18006 {
18007 0,
18008 ((combo->width+1)*(combo->height+1)*(1)),
18009 ((combo->width+1)*(combo->height+1)*(2)),
18010 ((combo->width+1)*(combo->height+1)*(3)),
18011 ((combo->width+1)*(combo->height+1)*(4)),
18012 ((combo->width+1)*(combo->height+1)*(5)),
18013 ((combo->width+1)*(combo->height+1)*(6))
18014 };
18015 int32_t new_layers[6] = {0,0,0,0,0,0};
18016 int32_t temp_layer = combo->layermask;
18017 int32_t temp_old = oldlayer;
18018 int32_t old_layers[6] = {0,0,0,0,0,0};
18019 int32_t k=1;
18020
18021 for(int32_t i=0; (i<6)&&(temp_layer!=0); j++,temp_layer>>=1,temp_old>>=1)
18022 {
18023 if(temp_layer&1)
18024 {
18025 new_layers[i] = j;
18026 //if(oldlayer&(1<<(j-1))) old_layers[i] = k++;
18027 i++;
18028 }
18029
18030 if(temp_old&1)
18031 {
18032 if(temp_layer&1)
18033 {
18034 old_layers[i-1] = k;
18035 }
18036
18037 k++;
18038 }
18039 }
18040
18041 for(int32_t i=0; i<new_count; i++)
18042 {
18043 if(i>=new_start[6])
18044 {
18045 //oldl=oldlayer>>(new_layers[5]-1);
18046 j=i-new_start[6];
18047
18048 if(((j/(combo->width+1))<=old_height)&&((j%(combo->width+1))<=old_width)&&(oldlayer&(1<<(new_layers[5]-1))))
18049 {
18050 combo->combos[i] = temp_combos[((j%(combo->width+1))+((old_width+1)*(j/(combo->width+1))))+(old_size*old_layers[5])];
18051 combo->csets[i] = temp_csets[((j%(combo->width+1))+((old_width+1)*(j/(combo->width+1))))+(old_size*old_layers[5])];
18052 }
18053 else
18054 {
18055 combo->combos[i] = 0;
18056 combo->csets[i] = 0;
18057 }
18058 }
18059 else if(i>=new_start[5])
18060 {
18061 //oldl=oldlayer>>(new_layers[4]-1);
18062 j=i-new_start[5];
18063
18064 if(((j/(combo->width+1))<=old_height)&&((j%(combo->width+1))<=old_width)&&(oldlayer&(1<<(new_layers[4]-1))))
18065 {
18066 combo->combos[i] = temp_combos[((j%(combo->width+1))+((old_width+1)*(j/(combo->width+1))))+(old_size*old_layers[4])];
18067 combo->csets[i] = temp_csets[((j%(combo->width+1))+((old_width+1)*(j/(combo->width+1))))+(old_size*old_layers[4])];
18068 }
18069 else
18070 {
18071 combo->combos[i] = 0;
18072 combo->csets[i] = 0;
18073 }
18074 }
18075 else if(i>=new_start[4])
18076 {
18077 //oldl=oldlayer>>(new_layers[3]-1);
18078 j=i-new_start[4];
18079
18080 if(((j/(combo->width+1))<=old_height)&&((j%(combo->width+1))<=old_width)&&(oldlayer&(1<<(new_layers[3]-1))))
18081 {
18082 combo->combos[i] = temp_combos[((j%(combo->width+1))+((old_width+1)*(j/(combo->width+1))))+(old_size*old_layers[3])];
18083 combo->csets[i] = temp_csets[((j%(combo->width+1))+((old_width+1)*(j/(combo->width+1))))+(old_size*old_layers[3])];
18084 }
18085 else
18086 {
18087 combo->combos[i] = 0;
18088 combo->csets[i] = 0;
18089 }
18090 }
18091 else if(i>=new_start[3])
18092 {
18093 //oldl=oldlayer>>(new_layers[2]-1);
18094 j=i-new_start[3];
18095
18096 if(((j/(combo->width+1))<=old_height)&&((j%(combo->width+1))<=old_width)&&(oldlayer&(1<<(new_layers[2]-1))))
18097 {
18098 combo->combos[i] = temp_combos[((j%(combo->width+1))+((old_width+1)*(j/(combo->width+1))))+(old_size*old_layers[2])];
18099 combo->csets[i] = temp_csets[((j%(combo->width+1))+((old_width+1)*(j/(combo->width+1))))+(old_size*old_layers[2])];
18100 }
18101 else
18102 {
18103 combo->combos[i] = 0;
18104 combo->csets[i] = 0;
18105 }
18106 }
18107 else if(i>=new_start[2])
18108 {
18109 //oldl=oldlayer>>(new_layers[1]-1);
18110 j=i-new_start[2];
18111
18112 if(((j/(combo->width+1))<=old_height)&&((j%(combo->width+1))<=old_width)&&(oldlayer&(1<<(new_layers[1]-1))))
18113 {
18114 combo->combos[i] = temp_combos[((j%(combo->width+1))+((old_width+1)*(j/(combo->width+1))))+(old_size*old_layers[1])];
18115 combo->csets[i] = temp_csets[((j%(combo->width+1))+((old_width+1)*(j/(combo->width+1))))+(old_size*old_layers[1])];
18116 }
18117 else
18118 {
18119 combo->combos[i] = 0;
18120 combo->csets[i] = 0;
18121 }
18122 }
18123 else if(i>=new_start[1])
18124 {
18125 //oldl=oldlayer>>(new_layers[0]-1);
18126 j=i-new_start[1];
18127
18128 if(((j/(combo->width+1))<=old_height)&&((j%(combo->width+1))<=old_width)&&(oldlayer&(1<<(new_layers[0]-1))))
18129 {
18130 combo->combos[i] = temp_combos[((j%(combo->width+1))+((old_width+1)*(j/(combo->width+1))))+(old_size*old_layers[0])];
18131 combo->csets[i] = temp_csets[((j%(combo->width+1))+((old_width+1)*(j/(combo->width+1))))+(old_size*old_layers[0])];
18132 }
18133 else
18134 {
18135 combo->combos[i] = 0;
18136 combo->csets[i] = 0;
18137 }
18138 }
18139 else if(i>=new_start[0])
18140 {
18141 if(((i/(combo->width+1))<=old_height)&&((i%(combo->width+1))<=old_width))
18142 {
18143 combo->combos[i] = temp_combos[(i%(combo->width+1))+((old_width+1)*(i/(combo->width+1)))];
18144 combo->csets[i] = temp_csets[(i%(combo->width+1))+((old_width+1)*(i/(combo->width+1)))];
18145 }
18146 else
18147 {
18148 combo->combos[i] = 0;
18149 combo->csets[i] = 0;
18150 }
18151 }
18152 }
18153
18154 set_comboaradio(combo->layermask);
18155 }
18156
18157 return ret;
18158 }
18159
18160 int32_t d_orgcomboa_proc(int32_t msg, DIALOG *d, int32_t c)
18161 {
18162 //these are here to bypass compiler warnings about unused arguments
18163 c=c;
18164
18165 int32_t down=0;
18166 int32_t selected=(d->flags&D_SELECTED)?1:0;
18167 int32_t last_draw;
18168
18169 switch(msg)
18170 {
18171
18172 case MSG_DRAW:
18173 {
18174 FONT *tfont=font;
18175 font=get_zc_font(font_lfont_l);
18176 jwin_draw_text_button(screen, d->x, d->y, d->w, d->h, (char*)d->dp, d->flags, true);
18177 font=tfont;
18178 }
18179 break;
18180
18181 case MSG_WANTFOCUS:
18182 return D_WANTFOCUS;
18183
18184 case MSG_KEY:
18185 /* close dialog? */
18186 onOrgComboAliases();
18187 return D_REDRAW;
18188
18189 /* or just toggle */
18190 /*d->flags ^= D_SELECTED;
18191 object_message(d, MSG_DRAW, 0);
18192 break;*/
18193
18194 case MSG_CLICK:
18195 last_draw = 0;
18196
18197 /* track the mouse until it is released */
18198 while(gui_mouse_b())
18199 {
18200 down = mouse_in_rect(d->x, d->y, d->w, d->h);
18201
18202 /* redraw? */
18203 if(last_draw != down)
18204 {
18205 if(down != selected)
18206 d->flags |= D_SELECTED;
18207 else
18208 d->flags &= ~D_SELECTED;
18209
18210 object_message(d, MSG_DRAW, 0);
18211 last_draw = down;
18212 }
18213
18214 /* let other objects continue to animate */
18215 broadcast_dialog_message(MSG_IDLE, 0);
18216 }
18217
18218 /* redraw in normal state */
18219 if(down)
18220 {
18221 if(d->flags&D_EXIT)
18222 {
18223 d->flags &= ~D_SELECTED;
18224 object_message(d, MSG_DRAW, 0);
18225 }
18226 }
18227
18228 /* should we close the dialog? */
18229 if(down)
18230 {
18231 onOrgComboAliases();
18232 return D_REDRAW;
18233 }
18234
18235 break;
18236 }
18237
18238 return D_O_K;
18239 }
18240
18241 int32_t d_comboabutton_proc(int32_t msg, DIALOG *d, int32_t c)
18242 {
18243 //these are here to bypass compiler warnings about unused arguments
18244 c=c;
18245
18246 int32_t down=0;
18247 int32_t selected=(d->flags&D_SELECTED)?1:0;
18248 int32_t last_draw;
18249
18250 switch(msg)
18251 {
18252
18253 case MSG_DRAW:
18254 {
18255 FONT *tfont=font;
18256 font=get_zc_font(font_lfont_l);
18257 jwin_draw_text_button(screen, d->x, d->y, d->w, d->h, (char*)d->dp, d->flags, true);
18258 font=tfont;
18259 }
18260 break;
18261
18262 case MSG_WANTFOCUS:
18263 return D_WANTFOCUS;
18264
18265 case MSG_KEY:
18266 /* close dialog? */
18267 onNewComboAlias();
18268 return D_REDRAW;
18269
18270 /* or just toggle */
18271 /*d->flags ^= D_SELECTED;
18272 object_message(d, MSG_DRAW, 0);
18273 break;*/
18274
18275 case MSG_CLICK:
18276 last_draw = 0;
18277
18278 /* track the mouse until it is released */
18279 while(gui_mouse_b())
18280 {
18281 down = mouse_in_rect(d->x, d->y, d->w, d->h);
18282
18283 /* redraw? */
18284 if(last_draw != down)
18285 {
18286 if(down != selected)
18287 d->flags |= D_SELECTED;
18288 else
18289 d->flags &= ~D_SELECTED;
18290
18291 object_message(d, MSG_DRAW, 0);
18292 last_draw = down;
18293 }
18294
18295 /* let other objects continue to animate */
18296 broadcast_dialog_message(MSG_IDLE, 0);
18297 }
18298
18299 /* redraw in normal state */
18300 if(down)
18301 {
18302 if(d->flags&D_EXIT)
18303 {
18304 d->flags &= ~D_SELECTED;
18305 object_message(d, MSG_DRAW, 0);
18306 }
18307 }
18308
18309 /* should we close the dialog? */
18310 if(down)
18311 {
18312 onNewComboAlias();
18313 return D_REDRAW;
18314 }
18315
18316 break;
18317 }
18318
18319 return D_O_K;
18320 }
18321
18322 int32_t d_comboacheck_proc(int32_t msg, DIALOG *d, int32_t c)
18323 {
18324 int32_t temp = d->flags&D_SELECTED;
18325 int32_t ret=jwin_checkfont_proc(msg,d,c);
18326
18327 if(temp != (d->flags&D_SELECTED))
18328 {
18329 return D_REDRAW;
18330 }
18331
18332 return ret;
18333 }
18334
18335 12 static ListData comboa_list(comboalist, &font);
18336
18337 static DIALOG editcomboa_dlg[] =
18338 {
18339 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
18340 { jwin_win_proc, 0, 0, 320, 240, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Combo Alias Edit", NULL, NULL },
18341 { jwin_button_proc, 148, 212, 61, 21, vc(14), vc(1), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
18342 { jwin_button_proc, 232, 212, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
18343 { jwin_frame_proc, 4+121, 28+81, 1, 1, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
18344 { d_comboabutton_proc, 25, 212, 81, 21, vc(14), vc(1), 'p', D_EXIT, 0, 0, (void *) "&Properties", NULL, NULL },
18345 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
18346 { d_comboa_radio_proc, 285, 44, 30, 8+1, vc(14), vc(1), 0, D_SELECTED, 0, 0, (void *) "0", NULL, NULL },
18347 { d_comboa_radio_proc, 285, 54, 30, 8+1, vc(14), vc(1), 0, 0, 0, 0, (void *) "1", NULL, NULL },
18348 { d_comboa_radio_proc, 285, 64, 30, 8+1, vc(14), vc(1), 0, 0, 0, 0, (void *) "2", NULL, NULL },
18349 { d_comboa_radio_proc, 285, 74, 30, 8+1, vc(14), vc(1), 0, 0, 0, 0, (void *) "3", NULL, NULL },
18350 { d_comboa_radio_proc, 285, 84, 30, 8+1, vc(14), vc(1), 0, 0, 0, 0, (void *) "4", NULL, NULL },
18351
18352 { d_comboa_radio_proc, 285, 94, 30, 8+1, vc(14), vc(1), 0, 0, 0, 0, (void *) "5", NULL, NULL },
18353 { d_comboa_radio_proc, 285, 104, 30, 8+1, vc(14), vc(1), 0, 0, 0, 0, (void *) "6", NULL, NULL },
18354 { d_comboacheck_proc, 285, 164, 17, 9, vc(12), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
18355 { d_comboa_proc, 6, 27, 256, 176, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
18356 { jwin_ctext_proc, 290, 176, 27, 8, 0, 0, 0, 0, 0, 0, (void *) "Only Show", NULL, NULL },
18357 { jwin_ctext_proc, 290, 186, 27, 8, 0, 0, 0, 0, 0, 0, (void *) "Current", NULL, NULL },
18358 { jwin_ctext_proc, 290, 196, 27, 8, 0, 0, 0, 0, 0, 0, (void *) "Layer", NULL, NULL },
18359 { jwin_ctext_proc, 290, 122, 27, 8, 0, 0, 0, 0, 0, 0, (void *) "Thumbnail", NULL, NULL },
18360 { jwin_frame_proc, 280, 132, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
18361 { d_comboat_proc, 282, 134, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
18362
18363 //21
18364 { d_orgcomboa_proc, 106, 212, 21, 21, vc(14), vc(1), 'p', D_EXIT, 0, 0, (void *) "&Org", NULL, NULL },
18365 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
18366 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
18367 };
18368
18369 int32_t getcurrentcomboalias()
18370 {
18371 return editcomboa_dlg[5].d1;
18372 }
18373
18374 int32_t d_comboa_radio_proc(int32_t msg,DIALOG *d,int32_t c)
18375 {
18376 int32_t temp = layer_cnt;
18377 int32_t ret = jwin_radiofont_proc(msg,d,c);
18378
18379 if(editcomboa_dlg[6].flags&D_SELECTED) layer_cnt=0;
18380 else if(editcomboa_dlg[7].flags&D_SELECTED) layer_cnt=1;
18381 else if(editcomboa_dlg[8].flags&D_SELECTED) layer_cnt=2;
18382 else if(editcomboa_dlg[9].flags&D_SELECTED) layer_cnt=3;
18383 else if(editcomboa_dlg[10].flags&D_SELECTED) layer_cnt=4;
18384 else if(editcomboa_dlg[11].flags&D_SELECTED) layer_cnt=5;
18385 else if(editcomboa_dlg[12].flags&D_SELECTED) layer_cnt=6;
18386
18387 if(temp != layer_cnt)
18388 {
18389 return D_REDRAW;
18390 }
18391
18392 return ret;
18393 }
18394
18395 int32_t set_comboaradio(byte layermask)
18396 {
18397 if(editcomboa_dlg[7].flags&D_SELECTED) editcomboa_dlg[7].flags &= ~D_SELECTED;
18398
18399 if(editcomboa_dlg[8].flags&D_SELECTED) editcomboa_dlg[8].flags &= ~D_SELECTED;
18400
18401 if(editcomboa_dlg[9].flags&D_SELECTED) editcomboa_dlg[9].flags &= ~D_SELECTED;
18402
18403 if(editcomboa_dlg[10].flags&D_SELECTED) editcomboa_dlg[10].flags &= ~D_SELECTED;
18404
18405 if(editcomboa_dlg[11].flags&D_SELECTED) editcomboa_dlg[11].flags &= ~D_SELECTED;
18406
18407 if(editcomboa_dlg[12].flags&D_SELECTED) editcomboa_dlg[12].flags &= ~D_SELECTED;
18408
18409 if(!(layermask&1)) editcomboa_dlg[7].flags |= D_DISABLED;
18410 else editcomboa_dlg[7].flags &= ~D_DISABLED;
18411
18412 if(!(layermask&2)) editcomboa_dlg[8].flags |= D_DISABLED;
18413 else editcomboa_dlg[8].flags &= ~D_DISABLED;
18414
18415 if(!(layermask&4)) editcomboa_dlg[9].flags |= D_DISABLED;
18416 else editcomboa_dlg[9].flags &= ~D_DISABLED;
18417
18418 if(!(layermask&8)) editcomboa_dlg[10].flags |= D_DISABLED;
18419 else editcomboa_dlg[10].flags &= ~D_DISABLED;
18420
18421 if(!(layermask&16)) editcomboa_dlg[11].flags |= D_DISABLED;
18422 else editcomboa_dlg[11].flags &= ~D_DISABLED;
18423
18424 if(!(layermask&32)) editcomboa_dlg[12].flags |= D_DISABLED;
18425 else editcomboa_dlg[12].flags &= ~D_DISABLED;
18426
18427 editcomboa_dlg[6].flags |= D_SELECTED;
18428 layer_cnt=0;
18429 return 1;
18430 }
18431
18432 int32_t onEditComboPool()
18433 {
18434 call_cpool_dlg(combo_pool_pos);
18435 return D_O_K;
18436 }
18437 int32_t onEditAutoCombo()
18438 {
18439 call_autocombo_dlg(combo_auto_pos);
18440 return D_O_K;
18441 }
18442 int32_t onEditComboAlias()
18443 {
18444 comboa_cnt = combo_apos;
18445 reset_combo_animations();
18446 reset_combo_animations2();
18447
18448 for(int32_t i=0; i<MAXCOMBOALIASES; i++)
18449 temp_aliases[i] = combo_aliases[i];
18450
18451 editcomboa_dlg[0].dp2 = get_zc_font(font_lfont);
18452 set_comboaradio(temp_aliases[comboa_cnt].layermask);
18453 editcomboa_dlg[5].d1 = comboa_cnt;
18454
18455 bool small_d1 = editcomboa_dlg[0].d1==0;
18456 large_dialog(editcomboa_dlg,2);
18457
18458 if(small_d1)
18459 {
18460 for(int32_t i=6; i<=12; i++)
18461 {
18462 editcomboa_dlg[i].w=30*1.5;
18463 editcomboa_dlg[i].h=9*1.5;
18464 }
18465
18466 editcomboa_dlg[13].w=17*1.5;
18467 editcomboa_dlg[13].h=9*1.5;
18468 editcomboa_dlg[4].w=81*1.5;
18469 editcomboa_dlg[4].h=21*1.5;
18470 editcomboa_dlg[4].dp2=get_zc_font(font_lfont_l);
18471 editcomboa_dlg[21].w=21*1.5;
18472 editcomboa_dlg[21].h=21*1.5;
18473 editcomboa_dlg[21].dp2=get_zc_font(font_lfont_l);
18474 }
18475
18476 int32_t ret=do_zqdialog(editcomboa_dlg,-1);
18477
18478 if(ret==1)
18479 {
18480 saved=false;
18481
18482 for(int32_t i=0; i<MAXCOMBOALIASES; i++)
18483 combo_aliases[i] = temp_aliases[i];
18484 }
18485
18486 setup_combo_animations();
18487 setup_combo_animations2();
18488 return D_O_K;
18489 }
18490 void call_calias_dlg(int index)
18491 {
18492 combo_apos = comboa_cnt = index;
18493 onEditComboAlias();
18494 }
18495
18496 static char ffcombo_str_buf[MAXFFCS];
18497 static char fflink_str_buf[MAXFFCS];
18498
18499 BITMAP* ffcur;
18500
18501 const char *ffcombolist(int32_t index, int32_t *list_size)
18502 {
18503 if(index>=0)
18504 {
18505 bound(index,0,MAXFFCS-1);
18506 sprintf(ffcombo_str_buf,"%d",index+1);
18507 return ffcombo_str_buf;
18508 }
18509
18510 *list_size=MAXFFCS;
18511 return NULL;
18512 }
18513
18514 12 static ListData ffcombo_list(ffcombolist, &font);
18515
18516 static DIALOG ffcombo_sel_dlg[] =
18517 {
18518 12 { jwin_win_proc, 0, 0, 200, 179, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Choose Freeform Combo", NULL, NULL },
18519 12 { jwin_button_proc, 35, 152, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Edit", NULL, NULL },
18520 12 { jwin_button_proc, 104, 152, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Done", NULL, NULL },
18521 12 { d_ffcombolist_proc, 11, 24, 49, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 1, 0, (void *) &ffcombo_list, NULL, NULL },
18522 12 { d_comboframe_proc, 68, 23, 20, 20, 0, 0, 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
18523 12 { d_bitmap_proc, 70, 25, 16, 16, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
18524 12 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
18525 12 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
18526 };
18527
18528 int32_t d_ffcombolist_proc(int32_t msg,DIALOG *d,int32_t c)
18529 {
18530 int32_t ret = jwin_droplist_proc(msg,d,c);
18531 int32_t d1 = d->d1;
18532 int32_t x=ffcombo_sel_dlg[0].x;
18533 int32_t y=ffcombo_sel_dlg[0].y;
18534 FONT *tempfont=(font);
18535 int32_t x2=text_length(tempfont, "Move Delay:")+4;
18536
18537 switch(msg)
18538 {
18539 case MSG_DRAW:
18540 if(!ffcur) return D_O_K;
18541
18542 BITMAP *buf = create_bitmap_ex(8,16,16);
18543
18544 if(buf)
18545 {
18546 clear_bitmap(buf);
18547 putcombo(buf,0,0,Map.CurrScr()->ffcs[d1].data,Map.CurrScr()->ffcs[d1].cset);
18548 stretch_blit(buf, ffcur, 0,0, 16, 16, 0, 0, ffcur->w, ffcur->h);
18549 destroy_bitmap(buf);
18550 }
18551
18552 object_message(&ffcombo_sel_dlg[5],MSG_DRAW,0);
18553
18554 int32_t xd = x+int32_t(68*1.5);
18555 int32_t y2 = y+int32_t(55*1.5);
18556 int32_t yd = 9;
18557
18558 rectfill(screen,xd,y2,xd+x2+100,y2+yd*14,jwin_pal[jcBOX]);
18559
18560 textprintf_ex(screen,tempfont,xd,y2,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"Combo #:");
18561 textprintf_ex(screen,tempfont,xd+x2,y2,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"%d",Map.CurrScr()->ffcs[d1].data);
18562
18563 textprintf_ex(screen,tempfont,xd,y2+yd,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"CSet #:");
18564 textprintf_ex(screen,tempfont,xd+x2,y2+yd,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"%d",Map.CurrScr()->ffcs[d1].cset);
18565
18566 textprintf_ex(screen,tempfont,xd,y2+yd*2,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"X Pos:");
18567 textprintf_ex(screen,tempfont,xd+x2,y2+yd*2,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"%.4f",Map.CurrScr()->ffcs[d1].x.getFloat());
18568
18569 textprintf_ex(screen,tempfont,xd,y2+yd*3,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"Y Pos:");
18570 textprintf_ex(screen,tempfont,xd+x2,y2+yd*3,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"%.4f",Map.CurrScr()->ffcs[d1].y.getFloat());
18571
18572 textprintf_ex(screen,tempfont,xd,y2+yd*4,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"X Speed:");
18573 textprintf_ex(screen,tempfont,xd+x2,y2+yd*4,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"%.4f",Map.CurrScr()->ffcs[d1].vx.getFloat());
18574
18575 textprintf_ex(screen,tempfont,xd,y2+yd*5,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"Y Speed:");
18576 textprintf_ex(screen,tempfont,xd+x2,y2+yd*5,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"%.4f",Map.CurrScr()->ffcs[d1].vy.getFloat());
18577
18578 textprintf_ex(screen,tempfont,xd,y2+yd*6,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"X Accel:");
18579 textprintf_ex(screen,tempfont,xd+x2,y2+yd*6,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"%.4f",Map.CurrScr()->ffcs[d1].ax.getFloat());
18580
18581 textprintf_ex(screen,tempfont,xd,y2+yd*7,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"Y Accel:");
18582 textprintf_ex(screen,tempfont,xd+x2,y2+yd*7,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"%.4f",Map.CurrScr()->ffcs[d1].ay.getFloat());
18583
18584 textprintf_ex(screen,tempfont,xd,y2+yd*8,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"Linked To:");
18585 textprintf_ex(screen,tempfont,xd+x2,y2+yd*8,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"%d",Map.CurrScr()->ffcs[d1].link);
18586
18587 textprintf_ex(screen,tempfont,xd,y2+yd*9,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"Move Delay:");
18588 textprintf_ex(screen,tempfont,xd+x2,y2+yd*9,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"%d",Map.CurrScr()->ffcs[d1].delay);
18589
18590 textprintf_ex(screen,tempfont,xd,y2+yd*10,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"Combo W:");
18591 textprintf_ex(screen,tempfont,xd+x2,y2+yd*10,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"%d",(Map.CurrScr()->ffEffectWidth(d1)));
18592
18593 textprintf_ex(screen,tempfont,xd,y2+yd*11,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"Combo H:");
18594 textprintf_ex(screen,tempfont,xd+x2,y2+yd*11,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"%d",(Map.CurrScr()->ffEffectHeight(d1)));
18595
18596 textprintf_ex(screen,tempfont,xd,y2+yd*12,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"Tile W:");
18597 textprintf_ex(screen,tempfont,xd+x2,y2+yd*12,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"%d",(Map.CurrScr()->ffTileWidth(d1)));
18598
18599 textprintf_ex(screen,tempfont,xd,y2+yd*13,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"Tile H:");
18600 textprintf_ex(screen,tempfont,xd+x2,y2+yd*13,jwin_pal[jcTEXTFG],jwin_pal[jcBOX],"%d",(Map.CurrScr()->ffTileHeight(d1)));
18601
18602 break;
18603 }
18604
18605 return ret;
18606 }
18607 int32_t onSelectFFCombo()
18608 {
18609 ffcombo_sel_dlg[0].dp2 = get_zc_font(font_lfont);
18610 ffcombo_sel_dlg[3].d1 = ff_combo;
18611 ffcur = create_bitmap_ex(8,32,32);
18612
18613 if(!ffcur) return D_O_K;
18614
18615 Map.CurrScr()->ensureFFC(MAXFFCS - 1);
18616 putcombo(ffcur,0,0,Map.CurrScr()->ffcs[ff_combo].data,Map.CurrScr()->ffcs[ff_combo].cset);
18617 ffcombo_sel_dlg[5].dp = ffcur;
18618
18619 bool resize = !(ffcombo_sel_dlg[0].d1);
18620 large_dialog(ffcombo_sel_dlg);
18621
18622 if(resize)
18623 {
18624 ffcombo_sel_dlg[5].x--;
18625 ffcombo_sel_dlg[5].y--;
18626 }
18627
18628 int32_t ret=do_zqdialog(ffcombo_sel_dlg,0);
18629
18630 while(ret==1)
18631 {
18632 ff_combo = ffcombo_sel_dlg[3].d1;
18633 mapscr* scr = active_visible_screen ? active_visible_screen->scr : Map.CurrScr();
18634 int screen = active_visible_screen ? active_visible_screen->screen : Map.getCurrScr();
18635 call_ffc_dialog(ff_combo, scr, screen);
18636 ret=do_zqdialog(ffcombo_sel_dlg,0);
18637 }
18638
18639 destroy_bitmap(ffcur);
18640 return D_O_K;
18641 }
18642
18643 const char *globalscriptlist(int32_t index, int32_t *list_size);
18644 12 static ListData globalscript_list(globalscriptlist, &font);
18645 const char *playerscriptlist(int32_t index, int32_t *list_size);
18646 12 static ListData playerscript_list(playerscriptlist, &font);
18647
18648 const char *ffscriptlist(int32_t index, int32_t *list_size);
18649
18650 12 static ListData ffscript_list(ffscriptlist, &font);
18651
18652 char *strip_decimals(char *string)
18653 {
18654 int32_t len=(int32_t)strlen(string);
18655 char *src=(char *)malloc(len+1);
18656 char *tmpsrc=src;
18657 memcpy(src,string,len+1);
18658 memset(src,0,len+1);
18659
18660 for(size_t i=0; string[i]&&i<=strlen(string); i++)
18661 {
18662 *tmpsrc=string[i];
18663
18664 if(*tmpsrc=='.')
18665 {
18666 while(string[i+1]=='.'&&i<=strlen(string))
18667 {
18668 i++;
18669 }
18670 }
18671
18672 tmpsrc++;
18673 }
18674
18675 memcpy(string,src,len);
18676 free(src);
18677 return string;
18678 }
18679
18680 // Unused??? -L 6/6/11
18681 char *clean_numeric_string(char *string)
18682 {
18683 bool found_sign=false;
18684 bool found_decimal=false;
18685 int32_t len=(int32_t)strlen(string);
18686 char *src=(char *)malloc(len+1);
18687 char *tmpsrc=src;
18688 memcpy(src,string,len+1);
18689 memset(src,0,len+1);
18690
18691 // strip out non-numerical characters
18692 for(size_t i=0; string[i]&&i<=strlen(string); i++)
18693 {
18694 *tmpsrc=string[i];
18695
18696 if(*tmpsrc!='.'&&*tmpsrc!='-'&&*tmpsrc!='+'&&!isdigit(*tmpsrc))
18697 {
18698 while(*tmpsrc!='.'&&*tmpsrc!='-'&&*tmpsrc!='+'&&!isdigit(*tmpsrc))
18699 {
18700 i++;
18701 }
18702 }
18703
18704 tmpsrc++;
18705 }
18706
18707 len=(int32_t)strlen(src);
18708 char *src2=(char *)malloc(len+1);
18709 tmpsrc=src2;
18710 memcpy(src,src2,len+1);
18711 memset(src2,0,len+1);
18712
18713 // second purge
18714 for(size_t i=0; src[i]&&i<=strlen(src); i++)
18715 {
18716 *tmpsrc=src[i];
18717
18718 if(*tmpsrc=='-'||*tmpsrc=='+')
18719 {
18720 if(found_sign||found_decimal)
18721 {
18722 while(*tmpsrc=='-'||*tmpsrc=='+')
18723 {
18724 i++;
18725 }
18726 }
18727
18728 found_sign=true;
18729 }
18730
18731 if(*tmpsrc=='.')
18732 {
18733 if(found_decimal)
18734 {
18735 while(*tmpsrc=='.')
18736 {
18737 i++;
18738 }
18739 }
18740
18741 found_decimal=true;
18742 }
18743
18744 tmpsrc++;
18745 }
18746
18747 sprintf(string, "%s", src2);
18748 free(src);
18749 free(src2);
18750 return string;
18751 }
18752
18753 script_struct biglobal[NUMSCRIPTGLOBAL+1]; //global script
18754 int32_t biglobal_cnt = -1;
18755 script_struct biffs[NUMSCRIPTFFC]; //ff script
18756 int32_t biffs_cnt = -1;
18757 script_struct biitems[NUMSCRIPTITEM]; //item script
18758 int32_t biitems_cnt = -1;
18759 script_struct binpcs[NUMSCRIPTGUYS]; //npc script
18760 int32_t binpcs_cnt = -1;
18761
18762 script_struct bilweapons[NUMSCRIPTWEAPONS]; //lweapon script
18763 int32_t bilweapons_cnt = -1;
18764
18765 script_struct bieweapons[NUMSCRIPTWEAPONS]; //eweapon script
18766 int32_t bieweapons_cnt = -1;
18767
18768 script_struct bihero[NUMSCRIPTHERO]; //link script
18769 int32_t bihero_cnt = -1;
18770
18771 script_struct biscreens[NUMSCRIPTSCREEN]; //screen (screendata) script
18772 int32_t biscreens_cnt = -1;
18773
18774 script_struct bidmaps[NUMSCRIPTSDMAP]; //dmap (dmapdata) script
18775 int32_t bidmaps_cnt = -1;
18776
18777 script_struct biditemsprites[NUMSCRIPTSITEMSPRITE]; //dmap (dmapdata) script
18778 int32_t biitemsprites_cnt = -1;
18779
18780 script_struct bidcomboscripts[NUMSCRIPTSCOMBODATA]; //dmap (dmapdata) script
18781 int32_t bidcomboscripts_cnt = -1;
18782 //static char ffscript_str_buf[32];
18783
18784 void build_biglobal_list()
18785 {
18786 biglobal[0].first = "(None)";
18787 biglobal[0].second = -1;
18788 biglobal_cnt = 1;
18789
18790 for(int32_t i = 0; i < NUMSCRIPTGLOBAL; ++i)
18791 {
18792 if(globalmap[i].scriptname.length()==0)
18793 continue;
18794
18795 stringstream ss;
18796 ss << globalmap[i].scriptname << " (" << i << ")"; // The word 'slot' preceding all of the numbers is a bit cluttersome. -L.
18797 biglobal[biglobal_cnt].first = ss.str();
18798 biglobal[biglobal_cnt].second = i;
18799 ++biglobal_cnt;
18800 }
18801
18802 // Blank out the rest of the list
18803 for(int32_t i=biglobal_cnt; i<NUMSCRIPTGLOBAL; ++i)
18804 {
18805 biglobal[i].first="";
18806 biglobal[i].second=-1;
18807 }
18808
18809 //Bubble sort! (doesn't account for gaps between scripts)
18810 for(int32_t i = 0; i < biglobal_cnt - 1; i++)
18811 {
18812 for(int32_t j = i + 1; j < biglobal_cnt; j++)
18813 {
18814 if(stricmp(biglobal[i].first.c_str(),biglobal[j].first.c_str()) > 0 && strcmp(biglobal[j].first.c_str(),""))
18815 zc_swap(biglobal[i],biglobal[j]);
18816 }
18817 }
18818
18819 biglobal_cnt = 0;
18820
18821 for(int32_t i = 0; i < NUMSCRIPTGLOBAL+1; ++i)
18822 if(biglobal[i].first.length() > 0)
18823 biglobal_cnt = i+1;
18824 }
18825
18826 6 void build_biffs_list()
18827 {
18828 6 biffs[0].first = "(None)";
18829 6 biffs[0].second = -1;
18830 6 biffs_cnt = 1;
18831
18832
2/2
✓ Branch 0 taken 3066 times.
✓ Branch 1 taken 6 times.
3072 for(int32_t i = 0; i < NUMSCRIPTFFC - 1; i++)
18833 {
18834
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 2987 times.
3066 if(ffcmap[i].scriptname.length()==0)
18835 2987 continue;
18836
18837 79 stringstream ss;
18838
5/10
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 79 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 79 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 79 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 79 times.
✗ Branch 9 not taken.
79 ss << ffcmap[i].scriptname << " (" << i+1 << ")"; // The word 'slot' preceding all of the numbers is a bit cluttersome. -L.
18839
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 biffs[biffs_cnt].first = ss.str();
18840 79 biffs[biffs_cnt].second = i;
18841 79 biffs_cnt++;
18842 79 }
18843
18844 // Blank out the rest of the list
18845
2/2
✓ Branch 0 taken 2987 times.
✓ Branch 1 taken 6 times.
2993 for(int32_t i=biffs_cnt; i<NUMSCRIPTFFC; i++)
18846 {
18847 2987 biffs[i].first="";
18848 2987 biffs[i].second=-1;
18849 2987 }
18850
18851 //Bubble sort! (doesn't account for gaps between scripts)
18852
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 6 times.
85 for(int32_t i = 0; i < biffs_cnt - 1; i++)
18853 {
18854
2/2
✓ Branch 0 taken 1383 times.
✓ Branch 1 taken 79 times.
1462 for(int32_t j = i + 1; j < biffs_cnt; j++)
18855 {
18856
3/4
✓ Branch 0 taken 540 times.
✓ Branch 1 taken 843 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 540 times.
1383 if(stricmp(biffs[i].first.c_str(),biffs[j].first.c_str()) > 0 && strcmp(biffs[j].first.c_str(),""))
18857 540 zc_swap(biffs[i],biffs[j]);
18858 1383 }
18859 79 }
18860
18861 6 biffs_cnt = 0;
18862
18863
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 6 times.
3078 for(int32_t i = 0; i < NUMSCRIPTFFC; i++)
18864
2/2
✓ Branch 0 taken 2987 times.
✓ Branch 1 taken 85 times.
3157 if(biffs[i].first.length() > 0)
18865 85 biffs_cnt = i+1;
18866 6 }
18867
18868 //npc scripts
18869 void build_binpcs_list()
18870 {
18871 binpcs[0].first = "(None)";
18872 binpcs[0].second = -1;
18873 binpcs_cnt = 1;
18874
18875 for(int32_t i = 0; i < NUMSCRIPTGUYS - 1; i++)
18876 {
18877 if(npcmap[i].scriptname.length()==0)
18878 continue;
18879
18880 stringstream ss;
18881 ss << npcmap[i].scriptname << " (" << i+1 << ")"; // The word 'slot' preceding all of the numbers is a bit cluttersome. -L.
18882 binpcs[binpcs_cnt].first = ss.str();
18883 binpcs[binpcs_cnt].second = i;
18884 binpcs_cnt++;
18885 }
18886
18887 // Blank out the rest of the list
18888 for(int32_t i=binpcs_cnt; i<NUMSCRIPTGUYS; i++)
18889 {
18890 binpcs[i].first="";
18891 binpcs[i].second=-1;
18892 }
18893
18894 //Bubble sort! (doesn't account for gaps between scripts)
18895 for(int32_t i = 0; i < binpcs_cnt - 1; i++)
18896 {
18897 for(int32_t j = i + 1; j < binpcs_cnt; j++)
18898 {
18899 if(stricmp(binpcs[i].first.c_str(),binpcs[j].first.c_str()) > 0 && strcmp(binpcs[j].first.c_str(),""))
18900 zc_swap(binpcs[i],binpcs[j]);
18901 }
18902 }
18903
18904 binpcs_cnt = 0;
18905
18906 for(int32_t i = 0; i < NUMSCRIPTGUYS; i++)
18907 if(binpcs[i].first.length() > 0)
18908 binpcs_cnt = i+1;
18909 }
18910
18911
18912 //lweapon scripts
18913 void build_bilweapons_list()
18914 {
18915 bilweapons[0].first = "(None)";
18916 bilweapons[0].second = -1;
18917 bilweapons_cnt = 1;
18918
18919 for(int32_t i = 0; i < NUMSCRIPTWEAPONS - 1; i++)
18920 {
18921 if(lwpnmap[i].scriptname.length()==0)
18922 continue;
18923
18924 stringstream ss;
18925 ss << lwpnmap[i].scriptname << " (" << i+1 << ")"; // The word 'slot' preceding all of the numbers is a bit cluttersome. -L.
18926 bilweapons[bilweapons_cnt].first = ss.str();
18927 bilweapons[bilweapons_cnt].second = i;
18928 bilweapons_cnt++;
18929 }
18930
18931 // Blank out the rest of the list
18932 for(int32_t i=bilweapons_cnt; i<NUMSCRIPTWEAPONS; i++)
18933 {
18934 bilweapons[i].first="";
18935 bilweapons[i].second=-1;
18936 }
18937
18938 //Bubble sort! (doesn't account for gaps between scripts)
18939 for(int32_t i = 0; i < bilweapons_cnt - 1; i++)
18940 {
18941 for(int32_t j = i + 1; j < bilweapons_cnt; j++)
18942 {
18943 if(stricmp(bilweapons[i].first.c_str(),bilweapons[j].first.c_str()) > 0 && strcmp(bilweapons[j].first.c_str(),""))
18944 zc_swap(bilweapons[i],bilweapons[j]);
18945 }
18946 }
18947
18948 bilweapons_cnt = 0;
18949
18950 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
18951 if(bilweapons[i].first.length() > 0)
18952 bilweapons_cnt = i+1;
18953 }
18954
18955 //eweapon scripts
18956 void build_bieweapons_list()
18957 {
18958 bieweapons[0].first = "(None)";
18959 bieweapons[0].second = -1;
18960 bieweapons_cnt = 1;
18961
18962 for(int32_t i = 0; i < NUMSCRIPTWEAPONS - 1; i++)
18963 {
18964 if(ewpnmap[i].scriptname.length()==0)
18965 continue;
18966
18967 stringstream ss;
18968 ss << ewpnmap[i].scriptname << " (" << i+1 << ")"; // The word 'slot' preceding all of the numbers is a bit cluttersome. -L.
18969 bieweapons[bieweapons_cnt].first = ss.str();
18970 bieweapons[bieweapons_cnt].second = i;
18971 bieweapons_cnt++;
18972 }
18973
18974 // Blank out the rest of the list
18975 for(int32_t i=bieweapons_cnt; i<NUMSCRIPTWEAPONS; i++)
18976 {
18977 bieweapons[i].first="";
18978 bieweapons[i].second=-1;
18979 }
18980
18981 //Bubble sort! (doesn't account for gaps between scripts)
18982 for(int32_t i = 0; i < bieweapons_cnt - 1; i++)
18983 {
18984 for(int32_t j = i + 1; j < bieweapons_cnt; j++)
18985 {
18986 if(stricmp(bieweapons[i].first.c_str(),bieweapons[j].first.c_str()) > 0 && strcmp(bieweapons[j].first.c_str(),""))
18987 zc_swap(bieweapons[i],bieweapons[j]);
18988 }
18989 }
18990
18991 bieweapons_cnt = 0;
18992
18993 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
18994 if(bieweapons[i].first.length() > 0)
18995 bieweapons_cnt = i+1;
18996 }
18997
18998 //player scripts
18999 void build_bihero_list()
19000 {
19001 bihero[0].first = "(None)";
19002 bihero[0].second = -1;
19003 bihero_cnt = 1;
19004
19005 for(int32_t i = 0; i < NUMSCRIPTHERO - 1; i++)
19006 {
19007 if(playermap[i].scriptname.length()==0)
19008 continue;
19009
19010 stringstream ss;
19011 ss << playermap[i].scriptname << " (" << i+1 << ")"; // The word 'slot' preceding all of the numbers is a bit cluttersome. -L.
19012 bihero[bihero_cnt].first = ss.str();
19013 bihero[bihero_cnt].second = i;
19014 bihero_cnt++;
19015 }
19016
19017 // Blank out the rest of the list
19018 for(int32_t i=bihero_cnt; i<NUMSCRIPTHERO; i++)
19019 {
19020 bihero[i].first="";
19021 bihero[i].second=-1;
19022 }
19023
19024 //Bubble sort! (doesn't account for gaps between scripts)
19025 for(int32_t i = 0; i < bihero_cnt - 1; i++)
19026 {
19027 for(int32_t j = i + 1; j < bihero_cnt; j++)
19028 {
19029 if(stricmp(bihero[i].first.c_str(),bihero[j].first.c_str()) > 0 && strcmp(bihero[j].first.c_str(),""))
19030 zc_swap(bihero[i],bihero[j]);
19031 }
19032 }
19033
19034 bihero_cnt = 0;
19035
19036 for(int32_t i = 0; i < NUMSCRIPTHERO; i++)
19037 if(bihero[i].first.length() > 0)
19038 bihero_cnt = i+1;
19039 }
19040
19041 //dmap scripts
19042 void build_bidmaps_list()
19043 {
19044 bidmaps[0].first = "(None)";
19045 bidmaps[0].second = -1;
19046 bidmaps_cnt = 1;
19047
19048 for(int32_t i = 0; i < NUMSCRIPTSDMAP - 1; i++)
19049 {
19050 if(dmapmap[i].scriptname.length()==0)
19051 continue;
19052
19053 stringstream ss;
19054 ss << dmapmap[i].scriptname << " (" << i+1 << ")"; // The word 'slot' preceding all of the numbers is a bit cluttersome. -L.
19055 bidmaps[bidmaps_cnt].first = ss.str();
19056 bidmaps[bidmaps_cnt].second = i;
19057 bidmaps_cnt++;
19058 }
19059
19060 // Blank out the rest of the list
19061 for(int32_t i=bidmaps_cnt; i<NUMSCRIPTSDMAP; i++)
19062 {
19063 bidmaps[i].first="";
19064 bidmaps[i].second=-1;
19065 }
19066
19067 //Bubble sort! (doesn't account for gaps between scripts)
19068 for(int32_t i = 0; i < bidmaps_cnt - 1; i++)
19069 {
19070 for(int32_t j = i + 1; j < bidmaps_cnt; j++)
19071 {
19072 if(stricmp(bidmaps[i].first.c_str(),bidmaps[j].first.c_str()) > 0 && strcmp(bidmaps[j].first.c_str(),""))
19073 zc_swap(bidmaps[i],bidmaps[j]);
19074 }
19075 }
19076
19077 bidmaps_cnt = 0;
19078
19079 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
19080 if(bidmaps[i].first.length() > 0)
19081 bidmaps_cnt = i+1;
19082 }
19083
19084 //screen scripts
19085 void build_biscreens_list()
19086 {
19087 biscreens[0].first = "(None)";
19088 biscreens[0].second = -1;
19089 biscreens_cnt = 1;
19090
19091 for(int32_t i = 0; i < NUMSCRIPTSCREEN - 1; i++)
19092 {
19093 if(screenmap[i].scriptname.length()==0)
19094 continue;
19095
19096 stringstream ss;
19097 ss << screenmap[i].scriptname << " (" << i+1 << ")"; // The word 'slot' preceding all of the numbers is a bit cluttersome. -L.
19098 biscreens[biscreens_cnt].first = ss.str();
19099 biscreens[biscreens_cnt].second = i;
19100 biscreens_cnt++;
19101 }
19102
19103 // Blank out the rest of the list
19104 for(int32_t i=biscreens_cnt; i<NUMSCRIPTSCREEN; i++)
19105 {
19106 biscreens[i].first="";
19107 biscreens[i].second=-1;
19108 }
19109
19110 //Bubble sort! (doesn't account for gaps between scripts)
19111 for(int32_t i = 0; i < biscreens_cnt - 1; i++)
19112 {
19113 for(int32_t j = i + 1; j < biscreens_cnt; j++)
19114 {
19115 if(stricmp(biscreens[i].first.c_str(),biscreens[j].first.c_str()) > 0 && strcmp(biscreens[j].first.c_str(),""))
19116 zc_swap(biscreens[i],biscreens[j]);
19117 }
19118 }
19119
19120 biscreens_cnt = 0;
19121
19122 for(int32_t i = 0; i < NUMSCRIPTSCREEN; i++)
19123 if(biscreens[i].first.length() > 0)
19124 biscreens_cnt = i+1;
19125 }
19126
19127 //screen scripts
19128 void build_biitemsprites_list()
19129 {
19130 biditemsprites[0].first = "(None)";
19131 biditemsprites[0].second = -1;
19132 biitemsprites_cnt = 1;
19133
19134 for(int32_t i = 0; i < NUMSCRIPTSITEMSPRITE - 1; i++)
19135 {
19136 if(itemspritemap[i].scriptname.length()==0)
19137 continue;
19138
19139 stringstream ss;
19140 ss << itemspritemap[i].scriptname << " (" << i+1 << ")"; // The word 'slot' preceding all of the numbers is a bit cluttersome. -L.
19141 biditemsprites[biitemsprites_cnt].first = ss.str();
19142 biditemsprites[biitemsprites_cnt].second = i;
19143 biitemsprites_cnt++;
19144 }
19145
19146 // Blank out the rest of the list
19147 for(int32_t i=biitemsprites_cnt; i<NUMSCRIPTSITEMSPRITE; i++)
19148 {
19149 biditemsprites[i].first="";
19150 biditemsprites[i].second=-1;
19151 }
19152
19153 //Bubble sort! (doesn't account for gaps between scripts)
19154 for(int32_t i = 0; i < biitemsprites_cnt - 1; i++)
19155 {
19156 for(int32_t j = i + 1; j < biitemsprites_cnt; j++)
19157 {
19158 if(stricmp(biditemsprites[i].first.c_str(),biditemsprites[j].first.c_str()) > 0 && strcmp(biditemsprites[j].first.c_str(),""))
19159 zc_swap(biditemsprites[i],biditemsprites[j]);
19160 }
19161 }
19162
19163 biitemsprites_cnt = 0;
19164
19165 for(int32_t i = 0; i < NUMSCRIPTSITEMSPRITE; i++)
19166 if(biditemsprites[i].first.length() > 0)
19167 biitemsprites_cnt = i+1;
19168 }
19169
19170 6 void build_biitems_list()
19171 {
19172 6 biitems[0].first = "(None)";
19173 6 biitems[0].second = -1;
19174 6 biitems_cnt = 1;
19175
19176
2/2
✓ Branch 0 taken 1530 times.
✓ Branch 1 taken 6 times.
1536 for(int32_t i = 0; i < NUMSCRIPTITEM - 1; i++, biitems_cnt++)
19177 {
19178 1530 stringstream ss;
19179
19180
4/6
✓ Branch 0 taken 1530 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1530 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13 times.
✓ Branch 5 taken 1517 times.
1530 if(!itemmap[i].isEmpty())
19181
5/10
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 13 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 13 times.
✗ Branch 9 not taken.
13 ss << itemmap[i].scriptname << " (" << i+1 << ")";
19182
19183
1/2
✓ Branch 0 taken 1530 times.
✗ Branch 1 not taken.
1530 biitems[biitems_cnt].first = ss.str();
19184 1530 biitems[biitems_cnt].second = i;
19185 1530 }
19186
19187
2/2
✓ Branch 0 taken 1530 times.
✓ Branch 1 taken 6 times.
1536 for(int32_t i = 0; i < biitems_cnt - 1; i++)
19188 {
19189
2/2
✓ Branch 0 taken 195840 times.
✓ Branch 1 taken 1530 times.
197370 for(int32_t j = i + 1; j < biitems_cnt; j++)
19190 {
19191
4/4
✓ Branch 0 taken 4760 times.
✓ Branch 1 taken 191080 times.
✓ Branch 2 taken 4757 times.
✓ Branch 3 taken 3 times.
195840 if(stricmp(biitems[i].first.c_str(), biitems[j].first.c_str()) > 0 && strcmp(biitems[j].first.c_str(),""))
19192 3 zc_swap(biitems[i], biitems[j]);
19193 195840 }
19194 1530 }
19195
19196 6 biitems_cnt = 0;
19197
19198
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 6 times.
1542 for(int32_t i = 0; i < NUMSCRIPTITEM; i++)
19199
2/2
✓ Branch 0 taken 1517 times.
✓ Branch 1 taken 19 times.
1555 if(biitems[i].first.length() > 0)
19200 19 biitems_cnt = i+1;
19201 6 }
19202
19203
19204 //dmap scripts
19205 void build_bidcomboscripts_list()
19206 {
19207 bidcomboscripts[0].first = "(None)";
19208 bidcomboscripts[0].second = -1;
19209 bidcomboscripts_cnt = 1;
19210
19211 for(int32_t i = 0; i < NUMSCRIPTSCOMBODATA - 1; i++)
19212 {
19213 if(comboscriptmap[i].scriptname.length()==0)
19214 continue;
19215
19216 stringstream ss;
19217 ss << comboscriptmap[i].scriptname << " (" << i+1 << ")"; // The word 'slot' preceding all of the numbers is a bit cluttersome. -L.
19218 bidcomboscripts[bidcomboscripts_cnt].first = ss.str();
19219 bidcomboscripts[bidcomboscripts_cnt].second = i;
19220 bidcomboscripts_cnt++;
19221 }
19222
19223 // Blank out the rest of the list
19224 for(int32_t i=bidcomboscripts_cnt; i<NUMSCRIPTSCOMBODATA; i++)
19225 {
19226 bidcomboscripts[i].first="";
19227 bidcomboscripts[i].second=-1;
19228 }
19229
19230 //Bubble sort! (doesn't account for gaps between scripts)
19231 for(int32_t i = 0; i < bidcomboscripts_cnt - 1; i++)
19232 {
19233 for(int32_t j = i + 1; j < bidcomboscripts_cnt; j++)
19234 {
19235 if(stricmp(bidcomboscripts[i].first.c_str(),bidcomboscripts[j].first.c_str()) > 0 && strcmp(bidcomboscripts[j].first.c_str(),""))
19236 zc_swap(bidcomboscripts[i],bidcomboscripts[j]);
19237 }
19238 }
19239
19240 bidcomboscripts_cnt = 0;
19241
19242 for(int32_t i = 0; i < NUMSCRIPTSCOMBODATA; i++)
19243 if(bidcomboscripts[i].first.length() > 0)
19244 bidcomboscripts_cnt = i+1;
19245 }
19246
19247
19248 const char *globalscriptlist(int32_t index, int32_t *list_size)
19249 {
19250 if(index < 0)
19251 {
19252 *list_size = biglobal_cnt;
19253 return NULL;
19254 }
19255
19256 return biglobal[index].first.c_str();
19257 }
19258
19259 const char *ffscriptlist(int32_t index, int32_t *list_size)
19260 {
19261 if(index < 0)
19262 {
19263 *list_size = biffs_cnt;
19264 return NULL;
19265 }
19266
19267 return biffs[index].first.c_str();
19268 }
19269
19270 const char *playerscriptlist(int32_t index, int32_t *list_size)
19271 {
19272 if(index < 0)
19273 {
19274 *list_size = bihero_cnt;
19275 return NULL;
19276 }
19277
19278 return bihero[index].first.c_str();
19279 }
19280
19281 const char *lweaponscriptlist(int32_t index, int32_t *list_size)
19282 {
19283 if(index < 0)
19284 {
19285 *list_size = bilweapons_cnt;
19286 return NULL;
19287 }
19288
19289 return bilweapons[index].first.c_str();
19290 }
19291
19292 const char *npcscriptlist(int32_t index, int32_t *list_size)
19293 {
19294 if(index < 0)
19295 {
19296 *list_size = binpcs_cnt;
19297 return NULL;
19298 }
19299
19300 return binpcs[index].first.c_str();
19301 }
19302
19303 static char itemscript_str_buf[32];
19304
19305 char *itemscriptlist(int32_t index, int32_t *list_size)
19306 {
19307 if(index>=0)
19308 {
19309 bound(index,0,255);
19310 sprintf(itemscript_str_buf,"%d: %s",index, ffcmap[index-1].scriptname.c_str());
19311 return itemscript_str_buf;
19312 }
19313
19314 *list_size=256;
19315 return NULL;
19316 }
19317
19318 static char ffscript_str_buf2[32];
19319
19320 const char *ffscriptlist2(int32_t index, int32_t *list_size)
19321 {
19322 if(index>=0)
19323 {
19324 char buf[20];
19325 bound(index,0,510);
19326
19327 if(ffcmap[index].scriptname=="")
19328 strcpy(buf, "<none>");
19329 else
19330 {
19331 strncpy(buf, ffcmap[index].scriptname.c_str(), 19);
19332 buf[19]='\0';
19333 }
19334
19335 sprintf(ffscript_str_buf2,"%d: %s",index+1, buf);
19336 return ffscript_str_buf2;
19337 }
19338
19339 *list_size=511;
19340 return NULL;
19341 }
19342
19343 static char itemscript_str_buf2[32];
19344
19345 const char *itemscriptlist2(int32_t index, int32_t *list_size)
19346 {
19347 if(index>=0)
19348 {
19349 char buf[20];
19350 bound(index,0,254);
19351
19352 if(itemmap[index].scriptname=="")
19353 strcpy(buf, "<none>");
19354 else
19355 {
19356 strncpy(buf, itemmap[index].scriptname.c_str(), 19);
19357 buf[19]='\0';
19358 }
19359
19360 sprintf(itemscript_str_buf2,"%d: %s",index+1, buf);
19361 return itemscript_str_buf2;
19362 }
19363
19364 *list_size=255;
19365 return NULL;
19366 }
19367
19368
19369 static char comboscript_str_buf2[32];
19370 const char *comboscriptlist2(int32_t index, int32_t *list_size)
19371 {
19372 if(index>=0)
19373 {
19374 char buf[20];
19375 bound(index,0,254);
19376
19377 if(comboscriptmap[index].scriptname=="")
19378 strcpy(buf, "<none>");
19379 else
19380 {
19381 strncpy(buf, comboscriptmap[index].scriptname.c_str(), 19);
19382 buf[19]='\0';
19383 }
19384
19385 sprintf(comboscript_str_buf2,"%d: %s",index+1, buf);
19386 return comboscript_str_buf2;
19387 }
19388
19389 *list_size=255;
19390 return NULL;
19391 }
19392
19393 static char gscript_str_buf2[40];
19394
19395 const char *gscriptlist2(int32_t index, int32_t *list_size)
19396 {
19397 if(index >= 0)
19398 {
19399 bound(index,0,3);
19400
19401 char buf[20];
19402
19403 if(globalmap[index].scriptname == "")
19404 strcpy(buf, "<none>");
19405 else
19406 {
19407 strncpy(buf, globalmap[index].scriptname.c_str(), 19);
19408 buf[19]='\0';
19409 }
19410
19411 switch(index)
19412 {
19413 case GLOBAL_SCRIPT_INIT:
19414 sprintf(gscript_str_buf2,"Initialization: %s", buf); break;
19415 case GLOBAL_SCRIPT_GAME:
19416 sprintf(gscript_str_buf2,"Active: %s", buf); break;
19417 case GLOBAL_SCRIPT_END:
19418 sprintf(gscript_str_buf2,"onExit: %s", buf); break;
19419 case GLOBAL_SCRIPT_ONSAVELOAD:
19420 sprintf(gscript_str_buf2,"onSaveLoad: %s", buf); break;
19421 case GLOBAL_SCRIPT_ONLAUNCH:
19422 sprintf(gscript_str_buf2,"onLaunch: %s", buf); break;
19423 case GLOBAL_SCRIPT_ONCONTGAME:
19424 sprintf(gscript_str_buf2,"onContGame: %s", buf); break;
19425 case GLOBAL_SCRIPT_F6:
19426 sprintf(gscript_str_buf2,"onF6Menu: %s", buf); break;
19427 case GLOBAL_SCRIPT_ONSAVE:
19428 sprintf(gscript_str_buf2,"onSave: %s", buf); break;
19429 }
19430
19431 return gscript_str_buf2;
19432 }
19433
19434 if(list_size != NULL)
19435 *list_size=4;
19436
19437 return NULL;
19438 }
19439
19440 static int32_t as_ffc_list[] = { 4, 5, 6, -1};
19441 static int32_t as_global_list[] = { 7, 8, 9, -1}; //Why does putting 15 in here not place my message only on the global tab? ~Joe
19442 static int32_t as_item_list[] = { 10, 11, 12, -1};
19443 static int32_t as_npc_list[] = { 18, 19, 20, -1}; //npc scripts TAB
19444 static int32_t as_lweapon_list[] = { 21, 22, 23, -1}; //lweapon scripts TAB
19445 static int32_t as_eweapon_list[] = { 24, 25, 26, -1}; //eweapon scripts TAB
19446 static int32_t as_hero_list[] = { 27, 28, 29, -1}; //hero scripts TAB
19447 static int32_t as_screen_list[] = { 30, 31, 32, -1}; //screendata scripts TAB
19448 static int32_t as_dmap_list[] = { 33, 34, 35, -1}; //dmapdata scripts TAB
19449 static int32_t as_itemsprite_list[] = { 36, 37, 38, -1}; //dmapdata scripts TAB
19450 static int32_t as_comboscript_list[] = { 39, 40, 41, -1}; //combodata scripts TAB
19451 static int32_t as_genericscript_list[] = { 45, 46, 47, -1}; //generic scripts TAB
19452 static int32_t as_subscreenscript_list[] = { 48, 49, 50, -1}; //generic scripts TAB
19453
19454 static TABPANEL assignscript_tabs[] =
19455 {
19456 // (text)
19457 { (char *)"FFC", D_SELECTED, as_ffc_list, 0, NULL },
19458 { (char *)"Global", 0, as_global_list, 0, NULL },
19459 { (char *)"Item", 0, as_item_list, 0, NULL },
19460 { (char *)"NPC", 0, as_npc_list, 0, NULL },
19461 { (char *)"LWeapon", 0, as_lweapon_list, 0, NULL },
19462 { (char *)"EWeapon", 0, as_eweapon_list, 0, NULL },
19463 { (char *)"Hero", 0, as_hero_list, 0, NULL },
19464 { (char *)"DMap", 0, as_dmap_list, 0, NULL },
19465 { (char *)"Screen", 0, as_screen_list, 0, NULL },
19466 { (char *)"Item Sprite", 0, as_itemsprite_list, 0, NULL },
19467 { (char *)"Combo", 0, as_comboscript_list, 0, NULL },
19468 { (char *)"Generic", 0, as_genericscript_list, 0, NULL },
19469 { (char *)"Subscreen", 0, as_subscreenscript_list, 0, NULL },
19470 { NULL, 0, NULL, 0, NULL }
19471 };
19472
19473 const char *assignffclist(int32_t index, int32_t *list_size)
19474 {
19475 if(index<0)
19476 {
19477 *list_size = (int32_t)ffcmap.size();
19478 return NULL;
19479 }
19480
19481 return ffcmap[index].output.c_str();
19482 }
19483
19484 const char *assigngloballist(int32_t index, int32_t *list_size)
19485 {
19486 if(index<0)
19487 {
19488 *list_size = (int32_t)globalmap.size();
19489 return NULL;
19490 }
19491
19492 return globalmap[index].output.c_str();
19493 }
19494
19495 const char *assigncombolist(int32_t index, int32_t *list_size)
19496 {
19497 if(index<0)
19498 {
19499 *list_size = (int32_t)comboscriptmap.size();
19500 return NULL;
19501 }
19502
19503 return comboscriptmap[index].output.c_str();
19504 }
19505
19506 const char *assigngenericlist(int32_t index, int32_t *list_size)
19507 {
19508 if(index<0)
19509 {
19510 *list_size = ((int32_t)genericmap.size());
19511 return NULL;
19512 }
19513
19514 return genericmap[index].output.c_str();
19515 }
19516
19517 const char *assignsubscreenlist(int32_t index, int32_t *list_size)
19518 {
19519 if(index<0)
19520 {
19521 *list_size = ((int32_t)subscreenmap.size());
19522 return NULL;
19523 }
19524
19525 return subscreenmap[index].output.c_str();
19526 }
19527
19528 const char *assignitemlist(int32_t index, int32_t *list_size)
19529 {
19530 if(index<0)
19531 {
19532 *list_size = (int32_t)itemmap.size();
19533 return NULL;
19534 }
19535
19536 return itemmap[index].output.c_str();
19537 }
19538 const char *assignnpclist(int32_t index, int32_t *list_size)
19539 {
19540 if(index<0)
19541 {
19542 *list_size = (int32_t)npcmap.size();
19543 return NULL;
19544 }
19545
19546 return npcmap[index].output.c_str();
19547 }
19548
19549 const char *assignlweaponlist(int32_t index, int32_t *list_size)
19550 {
19551 if(index<0)
19552 {
19553 *list_size = (int32_t)lwpnmap.size();
19554 return NULL;
19555 }
19556
19557 return lwpnmap[index].output.c_str();
19558 }
19559
19560 const char *assigneweaponlist(int32_t index, int32_t *list_size)
19561 {
19562 if(index<0)
19563 {
19564 *list_size = (int32_t)ewpnmap.size();
19565 return NULL;
19566 }
19567
19568 return ewpnmap[index].output.c_str();
19569 }
19570
19571 const char *assignplayerlist(int32_t index, int32_t *list_size)
19572 {
19573 if(index<0)
19574 {
19575 *list_size = (int32_t)playermap.size();
19576 return NULL;
19577 }
19578
19579 return playermap[index].output.c_str();
19580 }
19581
19582 const char *assigndmaplist(int32_t index, int32_t *list_size)
19583 {
19584 if(index<0)
19585 {
19586 *list_size = (int32_t)dmapmap.size();
19587 return NULL;
19588 }
19589
19590 return dmapmap[index].output.c_str();
19591 }
19592
19593 const char *assignscreenlist(int32_t index, int32_t *list_size)
19594 {
19595 if(index<0)
19596 {
19597 *list_size = (int32_t)screenmap.size();
19598 return NULL;
19599 }
19600
19601 return screenmap[index].output.c_str();
19602 }
19603
19604 const char *assignitemspritelist(int32_t index, int32_t *list_size)
19605 {
19606 if(index<0)
19607 {
19608 *list_size = (int32_t)itemspritemap.size();
19609 return NULL;
19610 }
19611
19612 return itemspritemap[index].output.c_str();
19613 }
19614
19615 const char *assignffcscriptlist(int32_t index, int32_t *list_size)
19616 {
19617 if(index<0)
19618 {
19619 *list_size = (int32_t)asffcscripts.size();
19620 return NULL;
19621 }
19622
19623 return asffcscripts[index].c_str();
19624 }
19625
19626 const char *assignglobalscriptlist(int32_t index, int32_t *list_size)
19627 {
19628 if(index<0)
19629 {
19630 *list_size = (int32_t)asglobalscripts.size();
19631 return NULL;
19632 }
19633
19634 return asglobalscripts[index].c_str();
19635 }
19636
19637 const char *assignitemscriptlist(int32_t index, int32_t *list_size)
19638 {
19639 if(index<0)
19640 {
19641 *list_size = (int32_t)asitemscripts.size();
19642 return NULL;
19643 }
19644
19645 return asitemscripts[index].c_str();
19646 }
19647
19648 const char *assignnpcscriptlist(int32_t index, int32_t *list_size)
19649 {
19650 if(index<0)
19651 {
19652 *list_size = (int32_t)asnpcscripts.size();
19653 return NULL;
19654 }
19655
19656 return asnpcscripts[index].c_str();
19657 }
19658
19659 const char *assignlweaponscriptlist(int32_t index, int32_t *list_size)
19660 {
19661 if(index<0)
19662 {
19663 *list_size = (int32_t)aslweaponscripts.size();
19664 return NULL;
19665 }
19666
19667 return aslweaponscripts[index].c_str();
19668 }
19669
19670 const char *assigneweaponscriptlist(int32_t index, int32_t *list_size)
19671 {
19672 if(index<0)
19673 {
19674 *list_size = (int32_t)aseweaponscripts.size();
19675 return NULL;
19676 }
19677
19678 return aseweaponscripts[index].c_str();
19679 }
19680
19681 const char *assignplayerscriptlist(int32_t index, int32_t *list_size)
19682 {
19683 if(index<0)
19684 {
19685 *list_size = (int32_t)asplayerscripts.size();
19686 return NULL;
19687 }
19688
19689 return asplayerscripts[index].c_str();
19690 }
19691
19692 const char *assigndmapscriptlist(int32_t index, int32_t *list_size)
19693 {
19694 if(index<0)
19695 {
19696 *list_size = (int32_t)asdmapscripts.size();
19697 return NULL;
19698 }
19699
19700 return asdmapscripts[index].c_str();
19701 }
19702
19703 const char *assignscreenscriptlist(int32_t index, int32_t *list_size)
19704 {
19705 if(index<0)
19706 {
19707 *list_size = (int32_t)asscreenscripts.size();
19708 return NULL;
19709 }
19710
19711 return asscreenscripts[index].c_str();
19712 }
19713
19714 const char *assignitemspritescriptlist(int32_t index, int32_t *list_size)
19715 {
19716 if(index<0)
19717 {
19718 *list_size = (int32_t)asitemspritescripts.size();
19719 return NULL;
19720 }
19721
19722 return asitemspritescripts[index].c_str();
19723 }
19724
19725 const char *assigncomboscriptlist(int32_t index, int32_t *list_size)
19726 {
19727 if(index<0)
19728 {
19729 *list_size = (int32_t)ascomboscripts.size();
19730 return NULL;
19731 }
19732
19733 return ascomboscripts[index].c_str();
19734 }
19735
19736 const char *assigngenericscriptlist(int32_t index, int32_t *list_size)
19737 {
19738 if(index<0)
19739 {
19740 *list_size = (int32_t)asgenericscripts.size();
19741 return NULL;
19742 }
19743
19744 return asgenericscripts[index].c_str();
19745 }
19746
19747 const char *assignsubscreenscriptlist(int32_t index, int32_t *list_size)
19748 {
19749 if(index<0)
19750 {
19751 *list_size = (int32_t)assubscreenscripts.size();
19752 return NULL;
19753 }
19754
19755 return assubscreenscripts[index].c_str();
19756 }
19757
19758 12 static ListData assignffc_list(assignffclist, &font);
19759 12 static ListData assignffcscript_list(assignffcscriptlist, &font);
19760 12 static ListData assignglobal_list(assigngloballist, &font);
19761 12 static ListData assignglobalscript_list(assignglobalscriptlist, &font);
19762 12 static ListData assignitem_list(assignitemlist, &font);
19763 12 static ListData assignitemscript_list(assignitemscriptlist, &font);
19764 12 static ListData assignnpc_list(assignnpclist, &font);
19765 12 static ListData assignnpcscript_list(assignnpcscriptlist, &font);
19766 12 static ListData assignlweapon_list(assignlweaponlist, &font);
19767 12 static ListData assignlweaponscript_list(assignlweaponscriptlist, &font);
19768 12 static ListData assigneweapon_list(assigneweaponlist, &font);
19769 12 static ListData assigneweaponscript_list(assigneweaponscriptlist, &font);
19770
19771 12 static ListData assignplayer_list(assignplayerlist, &font);
19772 12 static ListData assignplayerscript_list(assignplayerscriptlist, &font);
19773
19774 12 static ListData assigndmap_list(assigndmaplist, &font);
19775 12 static ListData assigndmapscript_list(assigndmapscriptlist, &font);
19776
19777 12 static ListData assignscreen_list(assignscreenlist, &font);
19778 12 static ListData assignscreenscript_list(assignscreenscriptlist, &font);
19779
19780 12 static ListData assignitemsprite_list(assignitemspritelist, &font);
19781 12 static ListData assignitemspritescript_list(assignitemspritescriptlist, &font);
19782
19783 12 static ListData assigncombo_list(assigncombolist, &font);
19784 12 static ListData assigncomboscript_list(assigncomboscriptlist, &font);
19785
19786 12 static ListData assigngeneric_list(assigngenericlist, &font);
19787 12 static ListData assigngenericscript_list(assigngenericscriptlist, &font);
19788
19789 12 static ListData assignsubscreen_list(assignsubscreenlist, &font);
19790 12 static ListData assignsubscreenscript_list(assignsubscreenscriptlist, &font);
19791
19792 static DIALOG assignscript_dlg[] =
19793 {
19794 // x y w h fg bg key flags d1 d2 dp
19795 12 { jwin_win_proc, 0, 0, 330, 236, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Assign Compiled Script", NULL, NULL },
19796 12 { jwin_tab_proc, 6, 25, 330-12, 130, 0, 0, 0, 0, 0, 0, assignscript_tabs, NULL, (void*)assignscript_dlg },
19797 12 { jwin_button_proc, 251, 207, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
19798 12 { jwin_button_proc, 182, 207, 61, 21, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
19799 12 { jwin_abclist_proc, 10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignffc_list, NULL, NULL },
19800 12 { jwin_abclist_proc, 174+10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignffcscript_list, NULL, NULL },
19801 //6
19802 12 { jwin_button_proc, 154+5, 93, 15, 10, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "<<", NULL, NULL },
19803 12 { jwin_abclist_proc, 10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignglobal_list, NULL, NULL },
19804 12 { jwin_abclist_proc, 174+10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignglobalscript_list, NULL, NULL },
19805 //9
19806 12 { jwin_button_proc, 154+5, 93, 15, 10, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "<<", NULL, NULL },
19807 12 { jwin_abclist_proc, 10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignitem_list, NULL, NULL },
19808 12 { jwin_abclist_proc, 174+10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignitemscript_list, NULL, NULL },
19809 //12
19810 12 { jwin_button_proc, 154+5, 93, 15, 10, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "<<", NULL, NULL },
19811 //13
19812 12 { jwin_check_proc, 22, 211, 90, 8, vc(14), vc(1), 0, 0, 1, 0, (void *) "Output ZASM code to allegro.log", NULL, NULL },
19813 12 { jwin_text_proc, 22, 178, 90, 24, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
19814 12 { d_dummy_proc, 0, 0, 0, 0, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
19815 //16
19816 12 { d_dummy_proc, 0, 0, 0, 0, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
19817 12 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
19818 //npc scripts
19819 12 { jwin_abclist_proc, 10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignnpc_list, NULL, NULL },
19820 12 { jwin_abclist_proc, 174+10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignnpcscript_list, NULL, NULL },
19821 //20
19822 12 { jwin_button_proc, 154+5, 93, 15, 10, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "<<", NULL, NULL },
19823 //21
19824 12 { jwin_abclist_proc, 10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignlweapon_list, NULL, NULL },
19825 12 { jwin_abclist_proc, 174+10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignlweaponscript_list, NULL, NULL },
19826 //23
19827 12 { jwin_button_proc, 154+5, 93, 15, 10, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "<<", NULL, NULL },
19828 //24
19829 12 { jwin_abclist_proc, 10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assigneweapon_list, NULL, NULL },
19830 12 { jwin_abclist_proc, 174+10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assigneweaponscript_list, NULL, NULL },
19831 //26
19832 12 { jwin_button_proc, 154+5, 93, 15, 10, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "<<", NULL, NULL },
19833 //27
19834 12 { jwin_abclist_proc, 10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignplayer_list, NULL, NULL },
19835 12 { jwin_abclist_proc, 174+10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignplayerscript_list, NULL, NULL },
19836 //29
19837 12 { jwin_button_proc, 154+5, 93, 15, 10, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "<<", NULL, NULL },
19838 //30
19839 12 { jwin_abclist_proc, 10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignscreen_list, NULL, NULL },
19840 12 { jwin_abclist_proc, 174+10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignscreenscript_list, NULL, NULL },
19841 //32
19842 12 { jwin_button_proc, 154+5, 93, 15, 10, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "<<", NULL, NULL },
19843 //33
19844 12 { jwin_abclist_proc, 10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assigndmap_list, NULL, NULL },
19845 12 { jwin_abclist_proc, 174+10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assigndmapscript_list, NULL, NULL },
19846 //35
19847 12 { jwin_button_proc, 154+5, 93, 15, 10, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "<<", NULL, NULL },
19848 //36
19849 12 { jwin_abclist_proc, 10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignitemsprite_list, NULL, NULL },
19850 12 { jwin_abclist_proc, 174+10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignitemspritescript_list, NULL, NULL },
19851 //38
19852 12 { jwin_button_proc, 154+5, 93, 15, 10, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "<<", NULL, NULL },
19853
19854 //39
19855 12 { jwin_abclist_proc, 10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assigncombo_list, NULL, NULL },
19856 12 { jwin_abclist_proc, 174+10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assigncomboscript_list, NULL, NULL },
19857 //41
19858 12 { jwin_button_proc, 154+5, 93, 15, 10, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "<<", NULL, NULL },
19859 12 { jwin_button_proc, 78-24, 158, 48, 16, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Script Info", NULL, NULL },
19860 12 { jwin_button_proc, 174+78-24, 158, 48, 16, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Script Info", NULL, NULL },
19861 12 { jwin_button_proc, 87+78-24, 158, 48, 16, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Clear", NULL, NULL },
19862 //45
19863 12 { jwin_abclist_proc, 10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assigngeneric_list, NULL, NULL },
19864 12 { jwin_abclist_proc, 174+10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assigngenericscript_list, NULL, NULL },
19865 //47
19866 12 { jwin_button_proc, 154+5, 93, 15, 10, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "<<", NULL, NULL },
19867 //48
19868 12 { jwin_abclist_proc, 10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignsubscreen_list, NULL, NULL },
19869 12 { jwin_abclist_proc, 174+10, 45, 136, 105, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0,0,0, 0, (void *)&assignsubscreenscript_list, NULL, NULL },
19870 //50
19871 12 { jwin_button_proc, 154+5, 93, 15, 10, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "<<", NULL, NULL },
19872 12 { jwin_check_proc, 22, 221, 90, 8, vc(14), vc(1), 0, 0, 1, 0, (void *) "...And output ZASM comments", NULL, NULL },
19873
19874 12 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
19875
19876 };
19877
19878 int32_t txtout(BITMAP* dest, const char* txt, int32_t x, int32_t y, bool disabled)
19879 {
19880 if(disabled)
19881 {
19882 gui_textout_ln(dest, font, (uint8_t*)txt, x+1, y+1, scheme[jcLIGHT], scheme[jcBOX], 0);
19883 return gui_textout_ln(dest, font, (uint8_t*)txt, x, y, scheme[jcMEDDARK], -1, 0);
19884 }
19885 else
19886 {
19887 return gui_textout_ln(dest, font, (uint8_t*)txt, x, y, scheme[jcBOXFG], scheme[jcBOX], 0);
19888 }
19889 }
19890
19891 int32_t jwin_zmeta_proc(int32_t msg, DIALOG *d, int32_t )
19892 {
19893 int32_t ret = D_O_K;
19894 ASSERT(d);
19895
19896 BITMAP* target = (msg==MSG_START ? NULL : screen);
19897 switch(msg)
19898 {
19899 case MSG_START:
19900 case MSG_DRAW:
19901 {
19902 FONT *oldfont = font;
19903
19904 if(d->dp2)
19905 {
19906 font = (FONT*)d->dp2;
19907 }
19908
19909 bool disabled = (d->flags & D_DISABLED) != 0;
19910 if(d->dp)
19911 {
19912 zasm_meta const& meta = *((zasm_meta*)d->dp);
19913 int32_t ind = -1;
19914 d->w = 0;
19915 if(!meta.valid())
19916 {
19917 d->w = txtout(target, "Invalid ZASM metadata found!", d->x, d->y, disabled);
19918 ++ind;
19919 }
19920
19921 int32_t t_w = 0;
19922 char buf[1024];
19923 memset(buf, 0, sizeof(buf));
19924 sprintf(buf, "ZASM Version: %d", meta.zasm_v);
19925 t_w = txtout(target, buf, d->x, d->y + ((++ind)*(text_height(font) + 3)), disabled);
19926 d->w = zc_max(d->w, t_w);
19927 memset(buf, 0, sizeof(buf));
19928 sprintf(buf, "Metadata Version: %d", meta.meta_v);
19929 t_w = txtout(target, buf, d->x, d->y + ((++ind)*(text_height(font) + 3)), disabled);
19930 d->w = zc_max(d->w, t_w);
19931 memset(buf, 0, sizeof(buf));
19932 sprintf(buf, "FFScript Version: %d", meta.ffscript_v);
19933 t_w = txtout(target, buf, d->x, d->y + ((++ind)*(text_height(font) + 3)), disabled);
19934 d->w = zc_max(d->w, t_w);
19935 memset(buf, 0, sizeof(buf));
19936 sprintf(buf, "Script Name: %s", meta.script_name.c_str());
19937 t_w = txtout(target, buf, d->x, d->y + ((++ind)*(text_height(font) + 3)), disabled);
19938 d->w = zc_max(d->w, t_w);
19939 memset(buf, 0, sizeof(buf));
19940 sprintf(buf, "Author: %s", meta.author.c_str());
19941 t_w = txtout(target, buf, d->x, d->y + ((++ind)*(text_height(font) + 3)), disabled);
19942 d->w = zc_max(d->w, t_w);
19943 memset(buf, 0, sizeof(buf));
19944 sprintf(buf, "Script Type: %s", get_script_name(meta.script_type).c_str());
19945 t_w = txtout(target, buf, d->x, d->y + ((++ind)*(text_height(font) + 3)), disabled);
19946 d->w = zc_max(d->w, t_w);
19947 for(auto q = 0; q < 4; ++q)
19948 {
19949 if(!meta.attributes[q].size())
19950 continue;
19951 memset(buf, 0, sizeof(buf));
19952 sprintf(buf, "Attributes[%d]: %s", q, meta.attributes[q].c_str());
19953 t_w = txtout(target, buf, d->x, d->y + ((++ind)*(text_height(font) + 3)), disabled);
19954 d->w = zc_max(d->w, t_w);
19955 }
19956 for(auto q = 0; q < 8; ++q)
19957 {
19958 if(!meta.attribytes[q].size())
19959 continue;
19960 memset(buf, 0, sizeof(buf));
19961 sprintf(buf, "Attribytes[%d]: %s", q, meta.attribytes[q].c_str());
19962 t_w = txtout(target, buf, d->x, d->y + ((++ind)*(text_height(font) + 3)), disabled);
19963 d->w = zc_max(d->w, t_w);
19964 }
19965 for(auto q = 0; q < 8; ++q)
19966 {
19967 if(!meta.attrishorts[q].size())
19968 continue;
19969 memset(buf, 0, sizeof(buf));
19970 sprintf(buf, "Attrishorts[%d]: %s", q, meta.attrishorts[q].c_str());
19971 t_w = txtout(target, buf, d->x, d->y + ((++ind)*(text_height(font) + 3)), disabled);
19972 d->w = zc_max(d->w, t_w);
19973 }
19974 bool indentrun = false;
19975 int32_t run_indent = txtout(NULL, "void run(", 0, 0, false);
19976 std::ostringstream oss;
19977 oss << "void run(";
19978 for(int32_t q = 0; q < 8; ++q)
19979 {
19980 if(!meta.run_idens[q].size() || meta.run_types[q] == ZMETA_NULL_TYPE) continue;
19981 if(q > 0)
19982 oss << ", ";
19983 string type_name = ZScript::getDataTypeName(meta.run_types[q]);
19984 lowerstr(type_name); //all lowercase for this output
19985 if(oss.str().size() > unsigned(indentrun ? 41 : 50))
19986 {
19987 memset(buf, 0, sizeof(buf));
19988 sprintf(buf, "%s", oss.str().c_str());
19989 t_w = txtout(target, buf, d->x + (indentrun ? run_indent : 0), d->y + ((++ind)*(text_height(font) + 3)), disabled) + (indentrun ? run_indent : 0);
19990 d->w = zc_max(d->w, t_w);
19991 oss.str("");
19992 indentrun = true;
19993 }
19994 oss << type_name.c_str() << " " << meta.run_idens[q];
19995 }
19996 oss << ");";
19997 memset(buf, 0, sizeof(buf));
19998 sprintf(buf, "%s", oss.str().c_str());
19999 t_w = txtout(target, buf, d->x + (indentrun ? run_indent : 0), d->y + ((++ind)*(text_height(font) + 3)), disabled) + (indentrun ? run_indent : 0);
20000 d->w = zc_max(d->w, t_w);
20001 memset(buf, 0, sizeof(buf));
20002 sprintf(buf, "Compiler Version: %d.%d.%d.%d", meta.compiler_v1, meta.compiler_v2, meta.compiler_v3, meta.compiler_v4);
20003 t_w = txtout(target, buf, d->x, d->y + ((++ind)*(text_height(font) + 3)), disabled);
20004 d->w = zc_max(d->w, t_w);
20005 memset(buf, 0, sizeof(buf));
20006 sprintf(buf, "Parser-generated: %s", (meta.flags & ZMETA_AUTOGEN)!=0 ? "TRUE" : "FALSE");
20007 t_w = txtout(target, buf, d->x, d->y + ((++ind)*(text_height(font) + 3)), disabled);
20008 d->w = zc_max(d->w, t_w);
20009 d->h = (++ind) * (text_height(font) + 3) -3;
20010 }
20011 else
20012 {
20013 d->w = txtout(target, "No ZASM metadata found!", d->x, d->y, disabled);
20014 d->h = text_height(font);
20015 }
20016
20017 if(d->dp3) //function trigger
20018 {
20019 typedef void (*funcType)(void);
20020 funcType func=reinterpret_cast<funcType>(d->dp3);
20021 func();
20022 }
20023
20024 font = oldfont;
20025 break;
20026 }
20027 }
20028
20029 return ret;
20030 }
20031
20032 void resize_scriptinfo_dlg();
20033
20034 static DIALOG scriptinfo_dlg[] =
20035 {
20036 // x y w h fg bg key flags d1 d2 dp
20037 { jwin_win_proc, 0, 0, 200, 150, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Script Metadata", NULL, NULL },
20038 { d_dummy_proc, 6, 25, 330-12, 130, 0, 0, 0, 0, 0, 0, assignscript_tabs, NULL, NULL },
20039 { jwin_button_proc, 70, 120, 60, 20, vc(14), vc(1), 'k', D_EXIT, 0, 0, (void *) "Done", NULL, NULL },
20040 { jwin_zmeta_proc, 50, 30, 100, 100, vc(14), vc(1), 0, 0, 0, 0, NULL, NULL, (void*)resize_scriptinfo_dlg },
20041
20042 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
20043 };
20044
20045 void resize_scriptinfo_dlg()
20046 {
20047 DIALOG *meta_proc = &scriptinfo_dlg[3], *window = &scriptinfo_dlg[0], *ok_button = &scriptinfo_dlg[2];
20048 int32_t bmargin = 15, hmargins = 30;
20049 jwin_ulalign_dialog(scriptinfo_dlg);
20050 window->w = hmargins*2 + meta_proc->w;
20051 meta_proc->x = hmargins;
20052 window->h = meta_proc->y + meta_proc->h + ok_button->h + bmargin*2;
20053 ok_button->x = (window->w/2)-(ok_button->w/2);
20054 ok_button->y = meta_proc->y + meta_proc->h + bmargin;
20055 jwin_center_dialog(scriptinfo_dlg);
20056 }
20057
20058 void showScriptInfo(zasm_meta const* meta)
20059 {
20060 scriptinfo_dlg[3].dp = (void*)meta;
20061 scriptinfo_dlg[0].dp2 = get_zc_font(font_lfont);
20062 large_dialog(scriptinfo_dlg);
20063 jwin_zmeta_proc(MSG_START,&scriptinfo_dlg[3],0); //Calculate size before calling dialog
20064 jwin_center_dialog(scriptinfo_dlg);
20065 do_zqdialog(scriptinfo_dlg,2);
20066 }
20067
20068 void write_includepaths();
20069 void call_compile_settings();
20070 int32_t onZScriptCompilerSettings()
20071 {
20072 call_compile_settings();
20073 return D_O_K;
20074 }
20075
20076 void doEditZScript()
20077 {
20078 if(do_box_edit(zScript, "ZScript Buffer", false, false))
20079 saved=false;
20080 }
20081
20082 std::string qst_cfg_header_from_path(std::string path);
20083 extern char *filepath;
20084 string get_box_cfg_hdr(int num)
20085 {
20086 if(num)
20087 return "misc";
20088 return qst_cfg_header_from_path(filepath);
20089 }
20090
20091 //{ Start type-specific import dlgs
20092 12 static ListData ffscript_sel_dlg_list(ffscriptlist2, &font);
20093 12 static ListData itemscript_sel_dlg_list(itemscriptlist2, &font);
20094 12 static ListData comboscript_sel_dlg_list(comboscriptlist2, &font);
20095 12 static ListData gscript_sel_dlg_list(gscriptlist2, &font);
20096 static char npcscript_str_buf2[32];
20097 const char *npcscriptlist2(int32_t index, int32_t *list_size)
20098 {
20099 if(index>=0)
20100 {
20101 char buf[20];
20102 bound(index,0,254);
20103
20104 if(npcmap[index].scriptname=="")
20105 strcpy(buf, "<none>");
20106 else
20107 {
20108 strncpy(buf, npcmap[index].scriptname.c_str(), 19);
20109 buf[19]='\0';
20110 }
20111
20112 sprintf(npcscript_str_buf2,"%d: %s",index+1, buf);
20113 return npcscript_str_buf2;
20114 }
20115
20116 *list_size=(NUMSCRIPTGUYS-1);
20117 return NULL;
20118 }
20119 12 static ListData npcscript_sel_dlg_list(npcscriptlist2, &font);
20120 static char lweaponscript_str_buf2[32];
20121 const char *lweaponscriptlist2(int32_t index, int32_t *list_size)
20122 {
20123 if(index>=0)
20124 {
20125 char buf[20];
20126 bound(index,0,254);
20127
20128 if(lwpnmap[index].scriptname=="")
20129 strcpy(buf, "<none>");
20130 else
20131 {
20132 strncpy(buf, lwpnmap[index].scriptname.c_str(), 19);
20133 buf[19]='\0';
20134 }
20135
20136 sprintf(lweaponscript_str_buf2,"%d: %s",index+1, buf);
20137 return lweaponscript_str_buf2;
20138 }
20139
20140 *list_size=(NUMSCRIPTWEAPONS-1);
20141 return NULL;
20142 }
20143 12 static ListData lweaponscript_sel_dlg_list(lweaponscriptlist2, &font);
20144 static char eweaponscript_str_buf2[32];
20145 const char *eweaponscriptlist2(int32_t index, int32_t *list_size)
20146 {
20147 if(index>=0)
20148 {
20149 char buf[20];
20150 bound(index,0,254);
20151
20152 if(ewpnmap[index].scriptname=="")
20153 strcpy(buf, "<none>");
20154 else
20155 {
20156 strncpy(buf, ewpnmap[index].scriptname.c_str(), 19);
20157 buf[19]='\0';
20158 }
20159
20160 sprintf(eweaponscript_str_buf2,"%d: %s",index+1, buf);
20161 return eweaponscript_str_buf2;
20162 }
20163
20164 *list_size=(NUMSCRIPTWEAPONS-1);
20165 return NULL;
20166 }
20167 12 static ListData eweaponscript_sel_dlg_list(eweaponscriptlist2, &font);
20168 static char playerscript_str_buf2[32];
20169 const char *playerscriptlist2(int32_t index, int32_t *list_size)
20170 {
20171 if(index>=0)
20172 {
20173 char buf[20];
20174 bound(index,0,3);
20175
20176 if(playermap[index].scriptname=="")
20177 strcpy(buf, "<none>");
20178 else
20179 {
20180 strncpy(buf, playermap[index].scriptname.c_str(), 19);
20181 buf[19]='\0';
20182 }
20183
20184 if(index==0)
20185 sprintf(playerscript_str_buf2,"Init: %s", buf);
20186
20187 if(index==1)
20188 sprintf(playerscript_str_buf2,"Active: %s", buf);
20189
20190 if(index==2)
20191 sprintf(playerscript_str_buf2,"Death: %s", buf);
20192
20193
20194 //sprintf(playerscript_str_buf2,"%d: %s",index+1, buf);
20195 return playerscript_str_buf2;
20196 }
20197
20198 *list_size=(NUMSCRIPTHERO-1);
20199 return NULL;
20200 }
20201 static char itemspritescript_str_buf2[32];
20202 const char *itemspritescriptlist2(int32_t index, int32_t *list_size)
20203 {
20204 if(index>=0)
20205 {
20206 char buf[20];
20207 bound(index,0,254);
20208
20209 if(itemspritemap[index].scriptname=="")
20210 strcpy(buf, "<none>");
20211 else
20212 {
20213 strncpy(buf, itemspritemap[index].scriptname.c_str(), 19);
20214 buf[19]='\0';
20215 }
20216
20217 sprintf(itemspritescript_str_buf2,"%d: %s",index+1, buf);
20218 return itemspritescript_str_buf2;
20219 }
20220
20221 *list_size=(NUMSCRIPTSITEMSPRITE-1);
20222 return NULL;
20223 }
20224 12 static ListData playerscript_sel_dlg_list(playerscriptlist2, &font);
20225 static char dmapscript_str_buf2[32];
20226 const char *dmapscriptlist2(int32_t index, int32_t *list_size)
20227 {
20228 if(index>=0)
20229 {
20230 char buf[20];
20231 bound(index,0,254);
20232
20233 if(dmapmap[index].scriptname=="")
20234 strcpy(buf, "<none>");
20235 else
20236 {
20237 strncpy(buf, dmapmap[index].scriptname.c_str(), 19);
20238 buf[19]='\0';
20239 }
20240
20241 sprintf(dmapscript_str_buf2,"%d: %s",index+1, buf);
20242 return dmapscript_str_buf2;
20243 }
20244
20245 *list_size=(NUMSCRIPTSDMAP-1);
20246 return NULL;
20247 }
20248 12 static ListData dmapscript_sel_dlg_list(dmapscriptlist2, &font);
20249 12 static ListData itemspritescript_sel_dlg_list(itemspritescriptlist2, &font);
20250 static char screenscript_str_buf2[32];
20251 const char *screenscriptlist2(int32_t index, int32_t *list_size)
20252 {
20253 if(index>=0)
20254 {
20255 char buf[20];
20256 bound(index,0,254);
20257
20258 if(screenmap[index].scriptname=="")
20259 strcpy(buf, "<none>");
20260 else
20261 {
20262 strncpy(buf, screenmap[index].scriptname.c_str(), 19);
20263 buf[19]='\0';
20264 }
20265
20266 sprintf(screenscript_str_buf2,"%d: %s",index+1, buf);
20267 return screenscript_str_buf2;
20268 }
20269
20270 *list_size=(NUMSCRIPTSCREEN-1);
20271 return NULL;
20272 }
20273 12 static ListData screenscript_sel_dlg_list(screenscriptlist2, &font);
20274 //} End type-specific import dlgs
20275
20276 6 void clear_map_states()
20277 {
20278
2/2
✓ Branch 0 taken 3066 times.
✓ Branch 1 taken 6 times.
3072 for(map<int32_t, script_slot_data>::iterator it = ffcmap.begin();
20279 3072 it != ffcmap.end(); ++it)
20280 {
20281 3066 (*it).second.format = SCRIPT_FORMAT_DEFAULT;
20282 3066 }
20283
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 6 times.
54 for(map<int32_t, script_slot_data>::iterator it = globalmap.begin();
20284 54 it != globalmap.end(); ++it)
20285 {
20286 48 (*it).second.format = SCRIPT_FORMAT_DEFAULT;
20287 48 }
20288
2/2
✓ Branch 0 taken 1530 times.
✓ Branch 1 taken 6 times.
1536 for(map<int32_t, script_slot_data>::iterator it = itemmap.begin();
20289 1536 it != itemmap.end(); ++it)
20290 {
20291 1530 (*it).second.format = SCRIPT_FORMAT_DEFAULT;
20292 1530 }
20293
2/2
✓ Branch 0 taken 1530 times.
✓ Branch 1 taken 6 times.
1536 for(map<int32_t, script_slot_data>::iterator it = npcmap.begin();
20294 1536 it != npcmap.end(); ++it)
20295 {
20296 1530 (*it).second.format = SCRIPT_FORMAT_DEFAULT;
20297 1530 }
20298
2/2
✓ Branch 0 taken 1530 times.
✓ Branch 1 taken 6 times.
1536 for(map<int32_t, script_slot_data>::iterator it = ewpnmap.begin();
20299 1536 it != ewpnmap.end(); ++it)
20300 {
20301 1530 (*it).second.format = SCRIPT_FORMAT_DEFAULT;
20302 1530 }
20303
2/2
✓ Branch 0 taken 1530 times.
✓ Branch 1 taken 6 times.
1536 for(map<int32_t, script_slot_data>::iterator it = lwpnmap.begin();
20304 1536 it != lwpnmap.end(); ++it)
20305 {
20306 1530 (*it).second.format = SCRIPT_FORMAT_DEFAULT;
20307 1530 }
20308
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 6 times.
30 for(map<int32_t, script_slot_data>::iterator it = playermap.begin();
20309 30 it != playermap.end(); ++it)
20310 {
20311 24 (*it).second.format = SCRIPT_FORMAT_DEFAULT;
20312 24 }
20313
2/2
✓ Branch 0 taken 1530 times.
✓ Branch 1 taken 6 times.
1536 for(map<int32_t, script_slot_data>::iterator it = dmapmap.begin();
20314 1536 it != dmapmap.end(); ++it)
20315 {
20316 1530 (*it).second.format = SCRIPT_FORMAT_DEFAULT;
20317 1530 }
20318
2/2
✓ Branch 0 taken 1530 times.
✓ Branch 1 taken 6 times.
1536 for(map<int32_t, script_slot_data>::iterator it = screenmap.begin();
20319 1536 it != screenmap.end(); ++it)
20320 {
20321 1530 (*it).second.format = SCRIPT_FORMAT_DEFAULT;
20322 1530 }
20323
2/2
✓ Branch 0 taken 1530 times.
✓ Branch 1 taken 6 times.
1536 for(map<int32_t, script_slot_data>::iterator it = itemspritemap.begin();
20324 1536 it != itemspritemap.end(); ++it)
20325 {
20326 1530 (*it).second.format = SCRIPT_FORMAT_DEFAULT;
20327 1530 }
20328
2/2
✓ Branch 0 taken 3066 times.
✓ Branch 1 taken 6 times.
3072 for(map<int32_t, script_slot_data>::iterator it = comboscriptmap.begin();
20329 3072 it != comboscriptmap.end(); ++it)
20330 {
20331 3066 (*it).second.format = SCRIPT_FORMAT_DEFAULT;
20332 3066 }
20333 6 }
20334
20335 void clearAssignSlotDlg()
20336 {
20337 assignscript_dlg[0].dp2 = get_zc_font(font_lfont);
20338 assignscript_dlg[4].d1 = -1;
20339 assignscript_dlg[5].d1 = -1;
20340 assignscript_dlg[7].d1 = -1;
20341 assignscript_dlg[8].d1 = -1;
20342 assignscript_dlg[10].d1 = -1;
20343 assignscript_dlg[11].d1 = -1;
20344 assignscript_dlg[13].flags = 0;
20345 }
20346
20347 void inc_script_name(string& name)
20348 {
20349 size_t pos = name.find_last_not_of("0123456789");
20350 pos = name.find_first_of("0123456789",pos);
20351 std::ostringstream oss;
20352 if(pos == string::npos)
20353 {
20354 oss << name << 2;
20355 }
20356 else
20357 {
20358 int32_t val = atoi(name.substr(pos).c_str());
20359 oss << name.substr(0,pos) << val+1;
20360 }
20361 name = oss.str();
20362 }
20363
20364 enum script_slot_type
20365 {
20366 type_ffc, type_global, type_itemdata, type_npc, type_lweapon, type_eweapon,
20367 type_hero, type_dmap, type_screen, type_itemsprite, type_combo, type_generic,
20368 type_subscreen, num_types
20369 };
20370 script_slot_type getType(ScriptType type)
20371 {
20372 switch(type)
20373 {
20374 case ScriptType::FFC: return type_ffc;
20375 case ScriptType::Global: return type_global;
20376 case ScriptType::Item: return type_itemdata;
20377 case ScriptType::NPC: return type_npc;
20378 case ScriptType::Lwpn: return type_lweapon;
20379 case ScriptType::Ewpn: return type_eweapon;
20380 case ScriptType::Hero: return type_hero;
20381 case ScriptType::DMap:
20382 case ScriptType::ScriptedActiveSubscreen:
20383 case ScriptType::ScriptedPassiveSubscreen:
20384 case ScriptType::OnMap:
20385 return type_dmap;
20386 case ScriptType::Generic: case ScriptType::GenericFrozen:
20387 return type_generic;
20388 case ScriptType::Screen: return type_screen;
20389 case ScriptType::ItemSprite: return type_itemsprite;
20390 case ScriptType::Combo: return type_combo;
20391 case ScriptType::EngineSubscreen: return type_subscreen;
20392 default: return type_ffc; //Default
20393 }
20394 }
20395 #define SLOTMSGFLAG_MISSING 0x01
20396 #define SLOTMSG_SIZE 512
20397 bool checkSkip(int32_t format, byte flags)
20398 {
20399 switch(format)
20400 {
20401 case SCRIPT_FORMAT_DEFAULT:
20402 return (flags != 0);
20403 case SCRIPT_FORMAT_INVALID:
20404 return ((flags & SLOTMSGFLAG_MISSING)==0);
20405 default: return true;
20406 }
20407 }
20408 void clearAllSlots(int32_t type, byte flags = 0)
20409 {
20410 bound(type,0,num_types-1);
20411 switch(type)
20412 {
20413 case type_ffc:
20414 {
20415 for(int32_t q = 0; q < NUMSCRIPTFFC-1; ++q)
20416 {
20417 if(checkSkip(ffcmap[q].format, flags)) continue;
20418 ffcmap[q].scriptname = "";
20419 ffcmap[q].format = SCRIPT_FORMAT_DEFAULT;
20420 }
20421 break;
20422 }
20423 case type_global:
20424 {
20425 //Start at 1 to not clear Init
20426 for(int32_t q = 1; q < NUMSCRIPTGLOBAL; ++q)
20427 {
20428 if(checkSkip(globalmap[q].format, flags)) continue;
20429 globalmap[q].scriptname = "";
20430 globalmap[q].format = SCRIPT_FORMAT_DEFAULT;
20431 }
20432 break;
20433 }
20434 case type_itemdata:
20435 {
20436 for(int32_t q = 0; q < NUMSCRIPTITEM-1; ++q)
20437 {
20438 if(checkSkip(itemmap[q].format, flags)) continue;
20439 itemmap[q].scriptname = "";
20440 itemmap[q].format = SCRIPT_FORMAT_DEFAULT;
20441 }
20442 break;
20443 }
20444 case type_npc:
20445 {
20446 for(int32_t q = 0; q < NUMSCRIPTGUYS-1; ++q)
20447 {
20448 if(checkSkip(npcmap[q].format, flags)) continue;
20449 npcmap[q].scriptname = "";
20450 npcmap[q].format = SCRIPT_FORMAT_DEFAULT;
20451 }
20452 break;
20453 }
20454 case type_lweapon:
20455 {
20456 for(int32_t q = 0; q < NUMSCRIPTWEAPONS-1; ++q)
20457 {
20458 if(checkSkip(lwpnmap[q].format, flags)) continue;
20459 lwpnmap[q].scriptname = "";
20460 lwpnmap[q].format = SCRIPT_FORMAT_DEFAULT;
20461 }
20462 break;
20463 }
20464 case type_eweapon:
20465 {
20466 for(int32_t q = 0; q < NUMSCRIPTWEAPONS-1; ++q)
20467 {
20468 if(checkSkip(ewpnmap[q].format, flags)) continue;
20469 ewpnmap[q].scriptname = "";
20470 ewpnmap[q].format = SCRIPT_FORMAT_DEFAULT;
20471 }
20472 break;
20473 }
20474 case type_hero:
20475 {
20476 for(int32_t q = 0; q < NUMSCRIPTHERO-1; ++q)
20477 {
20478 if(checkSkip(playermap[q].format, flags)) continue;
20479 playermap[q].scriptname = "";
20480 playermap[q].format = SCRIPT_FORMAT_DEFAULT;
20481 }
20482 break;
20483 }
20484 case type_dmap:
20485 {
20486 for(int32_t q = 0; q < NUMSCRIPTSDMAP-1; ++q)
20487 {
20488 if(checkSkip(dmapmap[q].format, flags)) continue;
20489 dmapmap[q].scriptname = "";
20490 dmapmap[q].format = SCRIPT_FORMAT_DEFAULT;
20491 }
20492 break;
20493 }
20494 case type_screen:
20495 {
20496 for(int32_t q = 0; q < NUMSCRIPTSCREEN-1; ++q)
20497 {
20498 if(checkSkip(screenmap[q].format, flags)) continue;
20499 screenmap[q].scriptname = "";
20500 screenmap[q].format = SCRIPT_FORMAT_DEFAULT;
20501 }
20502 break;
20503 }
20504 case type_itemsprite:
20505 {
20506 for(int32_t q = 0; q < NUMSCRIPTSITEMSPRITE-1; ++q)
20507 {
20508 if(checkSkip(itemspritemap[q].format, flags)) continue;
20509 itemspritemap[q].scriptname = "";
20510 itemspritemap[q].format = SCRIPT_FORMAT_DEFAULT;
20511 }
20512 break;
20513 }
20514 case type_combo:
20515 {
20516 for(int32_t q = 0; q < NUMSCRIPTSCOMBODATA-1; ++q)
20517 {
20518 if(checkSkip(comboscriptmap[q].format, flags)) continue;
20519 comboscriptmap[q].scriptname = "";
20520 comboscriptmap[q].format = SCRIPT_FORMAT_DEFAULT;
20521 }
20522 break;
20523 }
20524 case type_generic:
20525 {
20526 for(int32_t q = 0; q < NUMSCRIPTSGENERIC-1; ++q)
20527 {
20528 if(checkSkip(genericmap[q].format, flags)) continue;
20529 genericmap[q].scriptname = "";
20530 genericmap[q].format = SCRIPT_FORMAT_DEFAULT;
20531 }
20532 break;
20533 }
20534 case type_subscreen:
20535 {
20536 for(int32_t q = 0; q < NUMSCRIPTSSUBSCREEN-1; ++q)
20537 {
20538 if(checkSkip(subscreenmap[q].format, flags)) continue;
20539 subscreenmap[q].scriptname = "";
20540 subscreenmap[q].format = SCRIPT_FORMAT_DEFAULT;
20541 }
20542 break;
20543 }
20544 }
20545 }
20546
20547 static bool doslots_log_output = false, doslots_comment_output = true;
20548 6 void setup_scriptslot_dlg(char* buf, byte flags)
20549 {
20550 //{ Set up the textbox at the bottom, and auto-resize height based on it
20551 6 int32_t prev_height = assignscript_dlg[14].h;
20552 6 memset(buf, 0, SLOTMSG_SIZE);
20553 //
20554 6 strcpy(buf, "Slots with matching names have been updated.\n");
20555
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
6 if(flags & SLOTMSGFLAG_MISSING)
20556 3 strcat(buf,"Scripts prefixed with '--' were not found, and will not function.\n");
20557 6 strcat(buf,"Global scripts named 'Init' will be appended to '~Init'");
20558 //
20559
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 SETFLAG(assignscript_dlg[13].flags, D_SELECTED, doslots_log_output);
20560
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 SETFLAG(assignscript_dlg[51].flags, D_SELECTED, doslots_comment_output);
20561 6 assignscript_dlg[14].dp = buf;
20562 6 object_message(&assignscript_dlg[14], MSG_START, 0); //Set the width/height
20563
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(int32_t diff = assignscript_dlg[14].h - prev_height) //resize dlg
20564 {
20565 6 int32_t prev_bottom = assignscript_dlg[14].y + prev_height;
20566
2/2
✓ Branch 0 taken 306 times.
✓ Branch 1 taken 6 times.
312 for(int32_t q = 1; assignscript_dlg[q].proc; ++q)
20567 {
20568
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 300 times.
306 if(q==14) continue; //Don't change self
20569
2/2
✓ Branch 0 taken 276 times.
✓ Branch 1 taken 24 times.
300 if(assignscript_dlg[q].y < prev_bottom) continue; //above proc
20570 24 assignscript_dlg[q].y += diff;
20571 24 }
20572 6 assignscript_dlg[0].h += diff;
20573 6 jwin_center_dialog(assignscript_dlg);
20574 6 }
20575 //}
20576 6 }
20577
20578 std::string global_slotnames[NUMSCRIPTGLOBAL] = {
20579 "Init",
20580 "Active",
20581 "onExit",
20582 "onSaveLoad",
20583 "onLaunch",
20584 "onContGame",
20585 "onF6Menu",
20586 "onSave",
20587 };
20588 std::string player_slotnames[NUMSCRIPTHERO-1] = {
20589 "Init",
20590 "Active",
20591 "onDeath",
20592 "onWin",
20593 };
20594 6 byte reload_scripts(map<string, disassembled_script_data> &scripts)
20595 {
20596 6 byte slotflags = 0;
20597 char temp[100];
20598
2/2
✓ Branch 0 taken 3066 times.
✓ Branch 1 taken 6 times.
3072 for(int32_t i = 0; i < NUMSCRIPTFFC-1; i++)
20599 {
20600
2/2
✓ Branch 0 taken 2987 times.
✓ Branch 1 taken 79 times.
3066 if(ffcmap[i].isEmpty())
20601 2987 sprintf(temp, "Slot %d:", i+1);
20602 else
20603 {
20604 79 sprintf(temp, "Slot %d:", i+1);
20605
2/2
✓ Branch 0 taken 73 times.
✓ Branch 1 taken 6 times.
79 if(scripts.find(ffcmap[i].scriptname) != scripts.end())
20606 73 ffcmap[i].format = SCRIPT_FORMAT_DEFAULT;
20607 else // Previously loaded script not found
20608 {
20609 6 ffcmap[i].format = SCRIPT_FORMAT_INVALID;
20610 6 slotflags |= SLOTMSGFLAG_MISSING;
20611 }
20612 }
20613 3066 ffcmap[i].slotname = temp;
20614 3066 ffcmap[i].update();
20615 3066 }
20616
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 6 times.
54 for(int32_t i = 0; i < NUMSCRIPTGLOBAL; i++)
20617 {
20618
1/2
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
48 globalmap[i].slotname=fmt::format("{}:",global_slotnames[i]);
20619
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 11 times.
48 if(!globalmap[i].isEmpty())
20620 {
20621
2/4
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
11 if(scripts.find(globalmap[i].scriptname) != scripts.end() || globalmap[i].scriptname == "~Init")
20622 11 globalmap[i].format = SCRIPT_FORMAT_DEFAULT;
20623 else // Unloaded
20624 {
20625 globalmap[i].format = SCRIPT_FORMAT_INVALID;
20626 slotflags |= SLOTMSGFLAG_MISSING;
20627 }
20628 11 }
20629 48 globalmap[i].update();
20630 48 }
20631
2/2
✓ Branch 0 taken 1530 times.
✓ Branch 1 taken 6 times.
1536 for(int32_t i = 0; i < NUMSCRIPTITEM-1; i++)
20632 {
20633
2/2
✓ Branch 0 taken 1517 times.
✓ Branch 1 taken 13 times.
1530 if(itemmap[i].isEmpty())
20634 1517 sprintf(temp, "Slot %d:", i+1);
20635 else
20636 {
20637 13 sprintf(temp, "Slot %d:", i+1);
20638
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(scripts.find(itemmap[i].scriptname) != scripts.end())
20639 13 itemmap[i].format = SCRIPT_FORMAT_DEFAULT;
20640 else // Previously loaded script not found
20641 {
20642 itemmap[i].format = SCRIPT_FORMAT_INVALID;
20643 slotflags |= SLOTMSGFLAG_MISSING;
20644 }
20645 }
20646 1530 itemmap[i].slotname = temp;
20647 1530 itemmap[i].update();
20648 1530 }
20649
2/2
✓ Branch 0 taken 1530 times.
✓ Branch 1 taken 6 times.
1536 for(int32_t i = 0; i < NUMSCRIPTGUYS-1; i++)
20650 {
20651
1/2
✓ Branch 0 taken 1530 times.
✗ Branch 1 not taken.
1530 if(npcmap[i].isEmpty())
20652 1530 sprintf(temp, "Slot %d:", i+1);
20653 else
20654 {
20655 sprintf(temp, "Slot %d:", i+1);
20656 if(scripts.find(npcmap[i].scriptname) != scripts.end())
20657 npcmap[i].format = SCRIPT_FORMAT_DEFAULT;
20658 else // Previously loaded script not found
20659 {
20660 npcmap[i].format = SCRIPT_FORMAT_INVALID;
20661 slotflags |= SLOTMSGFLAG_MISSING;
20662 }
20663 }
20664 1530 npcmap[i].slotname = temp;
20665 1530 npcmap[i].update();
20666 1530 }
20667
2/2
✓ Branch 0 taken 1530 times.
✓ Branch 1 taken 6 times.
1536 for(int32_t i = 0; i < NUMSCRIPTWEAPONS-1; i++)
20668 {
20669
1/2
✓ Branch 0 taken 1530 times.
✗ Branch 1 not taken.
1530 if(ewpnmap[i].isEmpty())
20670 1530 sprintf(temp, "Slot %d:", i+1);
20671 else
20672 {
20673 sprintf(temp, "Slot %d:", i+1);
20674 if(scripts.find(ewpnmap[i].scriptname) != scripts.end())
20675 ewpnmap[i].format = SCRIPT_FORMAT_DEFAULT;
20676 else // Previously loaded script not found
20677 {
20678 ewpnmap[i].format = SCRIPT_FORMAT_INVALID;
20679 slotflags |= SLOTMSGFLAG_MISSING;
20680 }
20681 }
20682 1530 ewpnmap[i].slotname = temp;
20683 1530 ewpnmap[i].update();
20684 1530 }
20685
2/2
✓ Branch 0 taken 1530 times.
✓ Branch 1 taken 6 times.
1536 for(int32_t i = 0; i < NUMSCRIPTWEAPONS-1; i++)
20686 {
20687
2/2
✓ Branch 0 taken 1529 times.
✓ Branch 1 taken 1 times.
1530 if(lwpnmap[i].isEmpty())
20688 1529 sprintf(temp, "Slot %d:", i+1);
20689 else
20690 {
20691 1 sprintf(temp, "Slot %d:", i+1);
20692
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(scripts.find(lwpnmap[i].scriptname) != scripts.end())
20693 1 lwpnmap[i].format = SCRIPT_FORMAT_DEFAULT;
20694 else // Previously loaded script not found
20695 {
20696 lwpnmap[i].format = SCRIPT_FORMAT_INVALID;
20697 slotflags |= SLOTMSGFLAG_MISSING;
20698 }
20699 }
20700 1530 lwpnmap[i].slotname = temp;
20701 1530 lwpnmap[i].update();
20702 1530 }
20703
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 6 times.
30 for(int32_t i = 0; i < NUMSCRIPTHERO-1; i++)
20704 {
20705
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 playermap[i].slotname=fmt::format("{}:",player_slotnames[i]);
20706
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!playermap[i].isEmpty())
20707 {
20708 if(scripts.find(playermap[i].scriptname) != scripts.end())
20709 playermap[i].format = SCRIPT_FORMAT_DEFAULT;
20710 else // Unloaded
20711 {
20712 playermap[i].format = SCRIPT_FORMAT_INVALID;
20713 slotflags |= SLOTMSGFLAG_MISSING;
20714 }
20715 }
20716 24 playermap[i].update();
20717 24 }
20718
2/2
✓ Branch 0 taken 1530 times.
✓ Branch 1 taken 6 times.
1536 for(int32_t i = 0; i < NUMSCRIPTSCREEN-1; i++)
20719 {
20720
2/2
✓ Branch 0 taken 1528 times.
✓ Branch 1 taken 2 times.
1530 if(screenmap[i].isEmpty())
20721 1528 sprintf(temp, "Slot %d:", i+1);
20722 else
20723 {
20724 2 sprintf(temp, "Slot %d:", i+1);
20725
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(scripts.find(screenmap[i].scriptname) != scripts.end())
20726 2 screenmap[i].format = SCRIPT_FORMAT_DEFAULT;
20727 else // Previously loaded script not found
20728 {
20729 screenmap[i].format = SCRIPT_FORMAT_INVALID;
20730 slotflags |= SLOTMSGFLAG_MISSING;
20731 }
20732 }
20733 1530 screenmap[i].slotname = temp;
20734 1530 screenmap[i].update();
20735 1530 }
20736
2/2
✓ Branch 0 taken 1530 times.
✓ Branch 1 taken 6 times.
1536 for(int32_t i = 0; i < NUMSCRIPTSDMAP-1; i++)
20737 {
20738
2/2
✓ Branch 0 taken 1525 times.
✓ Branch 1 taken 5 times.
1530 if(dmapmap[i].isEmpty())
20739 1525 sprintf(temp, "Slot %d:", i+1);
20740 else
20741 {
20742 5 sprintf(temp, "Slot %d:", i+1);
20743
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(scripts.find(dmapmap[i].scriptname) != scripts.end())
20744 5 dmapmap[i].format = SCRIPT_FORMAT_DEFAULT;
20745 else // Previously loaded script not found
20746 {
20747 dmapmap[i].format = SCRIPT_FORMAT_INVALID;
20748 slotflags |= SLOTMSGFLAG_MISSING;
20749 }
20750 }
20751 1530 dmapmap[i].slotname = temp;
20752 1530 dmapmap[i].update();
20753 1530 }
20754
2/2
✓ Branch 0 taken 1530 times.
✓ Branch 1 taken 6 times.
1536 for(int32_t i = 0; i < NUMSCRIPTSITEMSPRITE-1; i++)
20755 {
20756
1/2
✓ Branch 0 taken 1530 times.
✗ Branch 1 not taken.
1530 if(itemspritemap[i].isEmpty())
20757 1530 sprintf(temp, "Slot %d:", i+1);
20758 else
20759 {
20760 sprintf(temp, "Slot %d:", i+1);
20761 if(scripts.find(itemspritemap[i].scriptname) != scripts.end())
20762 itemspritemap[i].format = SCRIPT_FORMAT_DEFAULT;
20763 else // Previously loaded script not found
20764 {
20765 itemspritemap[i].format = SCRIPT_FORMAT_INVALID;
20766 slotflags |= SLOTMSGFLAG_MISSING;
20767 }
20768 }
20769 1530 itemspritemap[i].slotname = temp;
20770 1530 itemspritemap[i].update();
20771 1530 }
20772
2/2
✓ Branch 0 taken 3066 times.
✓ Branch 1 taken 6 times.
3072 for(int32_t i = 0; i < NUMSCRIPTSCOMBODATA-1; i++)
20773 {
20774
1/2
✓ Branch 0 taken 3066 times.
✗ Branch 1 not taken.
3066 if(comboscriptmap[i].isEmpty())
20775 3066 sprintf(temp, "Slot %d:", i+1);
20776 else
20777 {
20778 sprintf(temp, "Slot %d:", i+1);
20779 if(scripts.find(comboscriptmap[i].scriptname) != scripts.end())
20780 comboscriptmap[i].format = SCRIPT_FORMAT_DEFAULT;
20781 else // Previously loaded script not found
20782 {
20783 comboscriptmap[i].format = SCRIPT_FORMAT_INVALID;
20784 slotflags |= SLOTMSGFLAG_MISSING;
20785 }
20786 }
20787 3066 comboscriptmap[i].slotname = temp;
20788 3066 comboscriptmap[i].update();
20789 3066 }
20790
2/2
✓ Branch 0 taken 3066 times.
✓ Branch 1 taken 6 times.
3072 for(int32_t i = 0; i < NUMSCRIPTSGENERIC-1; i++)
20791 {
20792
2/2
✓ Branch 0 taken 3047 times.
✓ Branch 1 taken 19 times.
3066 if(genericmap[i].isEmpty())
20793 3047 sprintf(temp, "Slot %d:", i+1);
20794 else
20795 {
20796 19 sprintf(temp, "Slot %d:", i+1);
20797
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 1 times.
19 if(scripts.find(genericmap[i].scriptname) != scripts.end())
20798 18 genericmap[i].format = SCRIPT_FORMAT_DEFAULT;
20799 else // Previously loaded script not found
20800 {
20801 1 genericmap[i].format = SCRIPT_FORMAT_INVALID;
20802 1 slotflags |= SLOTMSGFLAG_MISSING;
20803 }
20804 }
20805 3066 genericmap[i].slotname = temp;
20806 3066 genericmap[i].update();
20807 3066 }
20808
2/2
✓ Branch 0 taken 1530 times.
✓ Branch 1 taken 6 times.
1536 for(int32_t i = 0; i < NUMSCRIPTSSUBSCREEN-1; i++)
20809 {
20810
1/2
✓ Branch 0 taken 1530 times.
✗ Branch 1 not taken.
1530 if(subscreenmap[i].isEmpty())
20811 1530 sprintf(temp, "Slot %d:", i+1);
20812 else
20813 {
20814 sprintf(temp, "Slot %d:", i+1);
20815 if(scripts.find(subscreenmap[i].scriptname) != scripts.end())
20816 subscreenmap[i].format = SCRIPT_FORMAT_DEFAULT;
20817 else // Previously loaded script not found
20818 {
20819 subscreenmap[i].format = SCRIPT_FORMAT_INVALID;
20820 slotflags |= SLOTMSGFLAG_MISSING;
20821 }
20822 }
20823 1530 subscreenmap[i].slotname = temp;
20824 1530 subscreenmap[i].update();
20825 1530 }
20826 6 return slotflags;
20827 }
20828
20829 void doClearSlots(byte* flags);
20830
20831 extern byte compile_success_sample, compile_error_sample,
20832 compile_finish_sample, compile_audio_volume;
20833 static map<string, disassembled_script_data> *doslot_scripts = nullptr;
20834 21510 bool handle_slot(script_slot_data& slotdata, script_data* scriptdata)
20835 {
20836
2/2
✓ Branch 0 taken 123 times.
✓ Branch 1 taken 21387 times.
21510 if(slotdata.hasScriptData())
20837 {
20838 123 auto& data = (*doslot_scripts)[slotdata.scriptname];
20839 123 scriptdata->meta = data.meta;
20840 123 scriptdata->pc = data.pc;
20841 123 scriptdata->end_pc = data.end_pc;
20842 123 scriptdata->zasm_script = zasm_scripts[0];
20843 123 }
20844
1/2
✓ Branch 0 taken 21387 times.
✗ Branch 1 not taken.
21387 else if(scriptdata)
20845 {
20846 21387 scriptdata->zasm_script = nullptr;
20847 21387 scriptdata->meta.zero();
20848 21387 scriptdata->pc = 0;
20849 21387 scriptdata->end_pc = 0;
20850 21387 }
20851 21510 return true;
20852 }
20853 78 bool handle_slot_map(map<int32_t, script_slot_data>& mp, int offs, script_data** scriptdata)
20854 {
20855
2/2
✓ Branch 0 taken 21510 times.
✓ Branch 1 taken 78 times.
21588 for(auto it = mp.begin(); it != mp.end(); it++)
20856 {
20857
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21510 times.
21510 if(!handle_slot(it->second, scriptdata[it->first + offs]))
20858 return false;
20859 21510 }
20860 78 return true;
20861 78 }
20862
20863 void smart_slot_named(map<string, disassembled_script_data> &scripts,
20864 vector<string> const& scriptnames, map<int32_t, script_slot_data>& mp,
20865 std::string* slotnames, int slotstart, int slotend)
20866 {
20867 for(int q = slotstart; q < slotend; ++q)
20868 {
20869 auto& lval = mp[q];
20870 if(!lval.isEmpty())
20871 continue; //occupied, leave alone
20872 bool done = false;
20873 if(!done) //Check case-sensitive
20874 for(size_t rind = 0; rind < scriptnames.size(); ++rind)
20875 {
20876 auto const& rval = scriptnames[rind];
20877 if(rval == "<none>") continue;
20878 if(rval == slotnames[q])
20879 { //Perfect match
20880 lval.updateName(rval);
20881 lval.format = scripts[lval.scriptname].format;
20882 done = true;
20883 break;
20884 }
20885 }
20886 if(!done) //Check case-insensitive
20887 for(size_t rind = 0; rind < scriptnames.size(); ++rind)
20888 {
20889 auto const& rval = scriptnames[rind];
20890 if(rval == "<none>") continue;
20891 string lc_rv = rval, lc_slot = slotnames[q];
20892 lowerstr(lc_rv);
20893 lowerstr(lc_slot);
20894 if(lc_rv == lc_slot)
20895 { //Insensitive match
20896 lval.updateName(rval);
20897 lval.format = scripts[lval.scriptname].format;
20898 break;
20899 }
20900 }
20901 }
20902 }
20903 void smart_slot_type(map<string, disassembled_script_data> &scripts,
20904 vector<string> const& scriptnames, map<int32_t, script_slot_data>& mp,
20905 int slotcount)
20906 {
20907 for(size_t rind = 0; rind < scriptnames.size(); ++rind)
20908 {
20909 auto const& rval = scriptnames[rind];
20910 if(rval == "<none>") continue;
20911 script_slot_data* first_open_slot = nullptr;
20912 bool done = false;
20913 for(int q = 0; q < slotcount; ++q)
20914 {
20915 auto& lval = mp[q];
20916 if(lval.isEmpty())
20917 {
20918 if(!first_open_slot)
20919 first_open_slot = &lval;
20920 }
20921 else if(lval.scriptname == rval)
20922 {
20923 done = true;
20924 break;
20925 }
20926 }
20927 if(!done)
20928 {
20929 if(!first_open_slot)
20930 break; //no slots left to assign to!
20931 first_open_slot->updateName(rval);
20932 first_open_slot->format = scripts[first_open_slot->scriptname].format;
20933 }
20934 }
20935 }
20936
20937 6 bool do_slots(vector<shared_ptr<ZScript::Opcode>> const& zasm,
20938 map<string, disassembled_script_data> &scripts, int assign_mode)
20939 {
20940 6 large_dialog(assignscript_dlg);
20941 6 int32_t ret = 3;
20942 6 char slots_msg[SLOTMSG_SIZE] = {0};
20943 6 byte slotflags = reload_scripts(scripts);
20944 6 setup_scriptslot_dlg(slots_msg, slotflags);
20945 6 bool retval = false;
20946
20947 6 popup_zqdialog_start();
20948
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 while(!assign_mode)
20949 {
20950 slotflags = reload_scripts(scripts);
20951 ret = do_zqdialog(assignscript_dlg, ret);
20952
20953 switch(ret)
20954 {
20955 case 0:
20956 case 2:
20957 //Cancel
20958 goto exit_do_slots;
20959
20960 case 3: goto auto_do_slots;
20961
20962 case 6:
20963 //<<, FFC
20964 {
20965 int32_t lind = assignscript_dlg[4].d1;
20966 int32_t rind = assignscript_dlg[5].d1;
20967
20968 if(lind < 0 || rind < 0)
20969 break;
20970
20971 if(asffcscripts[rind] == "<none>")
20972 {
20973 ffcmap[lind].scriptname = "";
20974 ffcmap[lind].format = SCRIPT_FORMAT_DEFAULT;
20975 }
20976 else
20977 {
20978 ffcmap[lind].updateName(asffcscripts[rind]);
20979 ffcmap[lind].format = scripts[ffcmap[lind].scriptname].format;
20980 }
20981
20982 break;
20983 }
20984 case 9:
20985 //<<, Global
20986 {
20987 int32_t lind = assignscript_dlg[7].d1;
20988 int32_t rind = assignscript_dlg[8].d1;
20989
20990 if(lind < 0 || rind < 0)
20991 break;
20992
20993 if(lind == 0)
20994 {
20995 jwin_alert("Error","ZScript reserves this slot.",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
20996 break;
20997 }
20998
20999 if(asglobalscripts[rind] == "<none>")
21000 {
21001 globalmap[lind].scriptname = "";
21002 globalmap[lind].format = SCRIPT_FORMAT_DEFAULT;
21003 }
21004 else
21005 {
21006 globalmap[lind].updateName(asglobalscripts[rind]);
21007 globalmap[lind].format = scripts[globalmap[lind].scriptname].format;
21008 }
21009
21010 break;
21011 }
21012 case 12:
21013 //<<, ITEM
21014 {
21015 int32_t lind = assignscript_dlg[10].d1;
21016 int32_t rind = assignscript_dlg[11].d1;
21017
21018 if(lind < 0 || rind < 0)
21019 break;
21020
21021 if(asitemscripts[rind] == "<none>")
21022 {
21023 itemmap[lind].scriptname = "";
21024 itemmap[lind].format = SCRIPT_FORMAT_DEFAULT;
21025 }
21026 else
21027 {
21028 itemmap[lind].updateName(asitemscripts[rind]);
21029 itemmap[lind].format = scripts[itemmap[lind].scriptname].format;
21030 }
21031
21032 break;
21033 }
21034 case 20:
21035 //<<, NPC
21036 {
21037 int32_t lind = assignscript_dlg[18].d1;
21038 int32_t rind = assignscript_dlg[19].d1;
21039
21040 if(lind < 0 || rind < 0)
21041 break;
21042
21043 if(asnpcscripts[rind] == "<none>")
21044 {
21045 npcmap[lind].scriptname = "";
21046 npcmap[lind].format = SCRIPT_FORMAT_DEFAULT;
21047 }
21048 else
21049 {
21050 npcmap[lind].updateName(asnpcscripts[rind]);
21051 npcmap[lind].format = scripts[npcmap[lind].scriptname].format;
21052 }
21053
21054 break;
21055 }
21056 case 23:
21057 //<<, LWeapon
21058 {
21059 int32_t lind = assignscript_dlg[21].d1;
21060 int32_t rind = assignscript_dlg[22].d1;
21061
21062 if(lind < 0 || rind < 0)
21063 break;
21064
21065 if(aslweaponscripts[rind] == "<none>")
21066 {
21067 lwpnmap[lind].scriptname = "";
21068 lwpnmap[lind].format = SCRIPT_FORMAT_DEFAULT;
21069 }
21070 else
21071 {
21072 lwpnmap[lind].updateName(aslweaponscripts[rind]);
21073 lwpnmap[lind].format = scripts[lwpnmap[lind].scriptname].format;
21074 }
21075
21076 break;
21077 }
21078 case 26:
21079 //<<, EWeapon
21080 {
21081 int32_t lind = assignscript_dlg[24].d1;
21082 int32_t rind = assignscript_dlg[25].d1;
21083
21084 if(lind < 0 || rind < 0)
21085 break;
21086
21087 if(aseweaponscripts[rind] == "<none>")
21088 {
21089 ewpnmap[lind].scriptname = "";
21090 ewpnmap[lind].format = SCRIPT_FORMAT_DEFAULT;
21091 }
21092 else
21093 {
21094 ewpnmap[lind].updateName(aseweaponscripts[rind]);
21095 ewpnmap[lind].format = scripts[ewpnmap[lind].scriptname].format;
21096 }
21097
21098 break;
21099 }
21100 case 29:
21101 //<<, Hero
21102 {
21103 int32_t lind = assignscript_dlg[27].d1;
21104 int32_t rind = assignscript_dlg[28].d1;
21105
21106 if(lind < 0 || rind < 0)
21107 break;
21108
21109 if(asplayerscripts[rind] == "<none>")
21110 {
21111 playermap[lind].scriptname = "";
21112 playermap[lind].format = SCRIPT_FORMAT_DEFAULT;
21113 }
21114 else
21115 {
21116 playermap[lind].updateName(asplayerscripts[rind]);
21117 playermap[lind].format = scripts[playermap[lind].scriptname].format;
21118 }
21119
21120 break;
21121 }
21122 case 32:
21123 //<<, Screendata
21124 {
21125 int32_t lind = assignscript_dlg[30].d1;
21126 int32_t rind = assignscript_dlg[31].d1;
21127
21128 if(lind < 0 || rind < 0)
21129 break;
21130
21131 if(asscreenscripts[rind] == "<none>")
21132 {
21133 screenmap[lind].scriptname = "";
21134 screenmap[lind].format = SCRIPT_FORMAT_DEFAULT;
21135 }
21136 else
21137 {
21138 screenmap[lind].updateName(asscreenscripts[rind]);
21139 screenmap[lind].format = scripts[screenmap[lind].scriptname].format;
21140 }
21141
21142 break;
21143 }
21144 case 35:
21145 //<<, dmapdata
21146 {
21147 int32_t lind = assignscript_dlg[33].d1;
21148 int32_t rind = assignscript_dlg[34].d1;
21149
21150 if(lind < 0 || rind < 0)
21151 break;
21152
21153 if(asdmapscripts[rind] == "<none>")
21154 {
21155 dmapmap[lind].scriptname = "";
21156 dmapmap[lind].format = SCRIPT_FORMAT_DEFAULT;
21157 }
21158 else
21159 {
21160 dmapmap[lind].updateName(asdmapscripts[rind]);
21161 dmapmap[lind].format = scripts[dmapmap[lind].scriptname].format;
21162 }
21163
21164 break;
21165 }
21166 case 38:
21167 //<<, itemsprite
21168 {
21169 int32_t lind = assignscript_dlg[36].d1;
21170 int32_t rind = assignscript_dlg[37].d1;
21171
21172 if(lind < 0 || rind < 0)
21173 break;
21174
21175 if(asitemspritescripts[rind] == "<none>")
21176 {
21177 itemspritemap[lind].scriptname = "";
21178 itemspritemap[lind].format = SCRIPT_FORMAT_DEFAULT;
21179 }
21180 else
21181 {
21182 itemspritemap[lind].updateName(asitemspritescripts[rind]);
21183 itemspritemap[lind].format = scripts[itemspritemap[lind].scriptname].format;
21184 }
21185
21186 break;
21187 }
21188 case 41:
21189 //<<, comboscript
21190 {
21191 int32_t lind = assignscript_dlg[39].d1;
21192 int32_t rind = assignscript_dlg[40].d1;
21193
21194 if(lind < 0 || rind < 0)
21195 break;
21196
21197 if(ascomboscripts[rind] == "<none>")
21198 {
21199 comboscriptmap[lind].scriptname = "";
21200 comboscriptmap[lind].format = SCRIPT_FORMAT_DEFAULT;
21201 }
21202 else
21203 {
21204 comboscriptmap[lind].updateName(ascomboscripts[rind]);
21205 comboscriptmap[lind].format = scripts[comboscriptmap[lind].scriptname].format;
21206 }
21207
21208 break;
21209 }
21210 case 47:
21211 //<<, generic script
21212 {
21213 int32_t lind = assignscript_dlg[45].d1;
21214 int32_t rind = assignscript_dlg[46].d1;
21215
21216 if(lind < 0 || rind < 0)
21217 break;
21218
21219 if(asgenericscripts[rind] == "<none>")
21220 {
21221 genericmap[lind].scriptname = "";
21222 genericmap[lind].format = SCRIPT_FORMAT_DEFAULT;
21223 }
21224 else
21225 {
21226 genericmap[lind].updateName(asgenericscripts[rind]);
21227 genericmap[lind].format = scripts[genericmap[lind].scriptname].format;
21228 }
21229
21230 break;
21231 }
21232 case 50:
21233 //<<, subscreen script
21234 {
21235 int32_t lind = assignscript_dlg[48].d1;
21236 int32_t rind = assignscript_dlg[49].d1;
21237
21238 if(lind < 0 || rind < 0)
21239 break;
21240
21241 if(assubscreenscripts[rind] == "<none>")
21242 {
21243 subscreenmap[lind].scriptname = "";
21244 subscreenmap[lind].format = SCRIPT_FORMAT_DEFAULT;
21245 }
21246 else
21247 {
21248 subscreenmap[lind].updateName(assubscreenscripts[rind]);
21249 subscreenmap[lind].format = scripts[subscreenmap[lind].scriptname].format;
21250 }
21251
21252 break;
21253 }
21254
21255 case 42:
21256 //Script Info, information
21257 {
21258 disassembled_script_data* target = nullptr;
21259 switch(get_selected_tab((TABPANEL*)assignscript_dlg[1].dp))
21260 {
21261 default:
21262 case 0: //FFC
21263 {
21264 int32_t id = assignscript_dlg[4].d1;
21265 if(id > -1 && ffcmap[id].hasScriptData())
21266 {
21267 target = &(scripts[ffcmap[id].scriptname]);
21268 }
21269 break;
21270 }
21271 case 1: //Global
21272 {
21273 int32_t id = assignscript_dlg[7].d1;
21274 if(id > -1 && globalmap[id].hasScriptData())
21275 {
21276 target = &(scripts[globalmap[id].scriptname]);
21277 }
21278 break;
21279 }
21280 case 2: //Item
21281 {
21282 int32_t id = assignscript_dlg[10].d1;
21283 if(id > -1 && itemmap[id].hasScriptData())
21284 {
21285 target = &(scripts[itemmap[id].scriptname]);
21286 }
21287 break;
21288 }
21289 case 3: //npc
21290 {
21291 int32_t id = assignscript_dlg[19].d1;
21292 if(id > -1 && npcmap[id].hasScriptData())
21293 {
21294 target = &(scripts[npcmap[id].scriptname]);
21295 }
21296 break;
21297 }
21298 case 4: //lweapon
21299 {
21300 int32_t id = assignscript_dlg[21].d1;
21301 if(id > -1 && lwpnmap[id].hasScriptData())
21302 {
21303 target = &(scripts[lwpnmap[id].scriptname]);
21304 }
21305 break;
21306 }
21307 case 5: //eweapon
21308 {
21309 int32_t id = assignscript_dlg[24].d1;
21310 if(id > -1 && ewpnmap[id].hasScriptData())
21311 {
21312 target = &(scripts[ewpnmap[id].scriptname]);
21313 }
21314 break;
21315 }
21316 case 6: //hero
21317 {
21318 int32_t id = assignscript_dlg[27].d1;
21319 if(id > -1 && playermap[id].hasScriptData())
21320 {
21321 target = &(scripts[playermap[id].scriptname]);
21322 }
21323 break;
21324 }
21325 case 7: //dmap
21326 {
21327 int32_t id = assignscript_dlg[33].d1;
21328 if(id > -1 && dmapmap[id].hasScriptData())
21329 {
21330 target = &(scripts[dmapmap[id].scriptname]);
21331 }
21332 break;
21333 }
21334 case 8: //screen
21335 {
21336 int32_t id = assignscript_dlg[30].d1;
21337 if(id > -1 && screenmap[id].hasScriptData())
21338 {
21339 target = &(scripts[screenmap[id].scriptname]);
21340 }
21341 break;
21342 }
21343 case 9: //itemsprite
21344 {
21345 int32_t id = assignscript_dlg[36].d1;
21346 if(id > -1 && itemspritemap[id].hasScriptData())
21347 {
21348 target = &(scripts[itemspritemap[id].scriptname]);
21349 }
21350 break;
21351 }
21352 case 10: //combo
21353 {
21354 int32_t id = assignscript_dlg[39].d1;
21355 if(id > -1 && comboscriptmap[id].hasScriptData())
21356 {
21357 target = &(scripts[comboscriptmap[id].scriptname]);
21358 }
21359 break;
21360 }
21361 case 11: //Generic
21362 {
21363 int32_t id = assignscript_dlg[45].d1;
21364 if(id > -1 && genericmap[id].hasScriptData())
21365 {
21366 target = &(scripts[genericmap[id].scriptname]);
21367 }
21368 break;
21369 }
21370 case 12: //Subscreen
21371 {
21372 int32_t id = assignscript_dlg[48].d1;
21373 if(id > -1 && subscreenmap[id].hasScriptData())
21374 {
21375 target = &(scripts[subscreenmap[id].scriptname]);
21376 }
21377 break;
21378 }
21379 }
21380 if(target)
21381 showScriptInfo(&target->meta);
21382 break;
21383 }
21384
21385 case 43:
21386 //Script Info, information
21387 {
21388 disassembled_script_data* target = NULL;
21389 switch(get_selected_tab((TABPANEL*)assignscript_dlg[1].dp))
21390 {
21391 default:
21392 case 0: //FFC
21393 {
21394 int32_t id = assignscript_dlg[5].d1;
21395 if(id < 0 || asffcscripts[id] == "<none>" || asffcscripts[id].at(0) == '-') break;
21396 target = &(scripts[asffcscripts[id]]);
21397 break;
21398 }
21399 case 1: //Global
21400 {
21401 int32_t id = assignscript_dlg[8].d1;
21402 if(id < 0 || asglobalscripts[id] == "<none>" || asglobalscripts[id].at(0) == '-') break;
21403 target = &(scripts[asglobalscripts[id]]);
21404 break;
21405 }
21406 case 2: //Item
21407 {
21408 int32_t id = assignscript_dlg[11].d1;
21409 if(id < 0 || asitemscripts[id] == "<none>" || asitemscripts[id].at(0) == '-') break;
21410 target = &(scripts[asitemscripts[id]]);
21411 break;
21412 }
21413 case 3: //npc
21414 {
21415 int32_t id = assignscript_dlg[20].d1;
21416 if(id < 0 || asnpcscripts[id] == "<none>" || asnpcscripts[id].at(0) == '-') break;
21417 target = &(scripts[asnpcscripts[id]]);
21418 break;
21419 }
21420 case 4: //lweapon
21421 {
21422 int32_t id = assignscript_dlg[22].d1;
21423 if(id < 0 || aslweaponscripts[id] == "<none>" || aslweaponscripts[id].at(0) == '-') break;
21424 target = &(scripts[aslweaponscripts[id]]);
21425 break;
21426 }
21427 case 5: //eweapon
21428 {
21429 int32_t id = assignscript_dlg[25].d1;
21430 if(id < 0 || aseweaponscripts[id] == "<none>" || aseweaponscripts[id].at(0) == '-') break;
21431 target = &(scripts[aseweaponscripts[id]]);
21432 break;
21433 }
21434 case 6: //hero
21435 {
21436 int32_t id = assignscript_dlg[28].d1;
21437 if(id < 0 || asplayerscripts[id] == "<none>" || asplayerscripts[id].at(0) == '-') break;
21438 target = &(scripts[asplayerscripts[id]]);
21439 break;
21440 }
21441 case 7: //dmap
21442 {
21443 int32_t id = assignscript_dlg[34].d1;
21444 if(id < 0 || asdmapscripts[id] == "<none>" || asdmapscripts[id].at(0) == '-') break;
21445 target = &(scripts[asdmapscripts[id]]);
21446 break;
21447 }
21448 case 8: //screen
21449 {
21450 int32_t id = assignscript_dlg[31].d1;
21451 if(id < 0 || asscreenscripts[id] == "<none>" || asscreenscripts[id].at(0) == '-') break;
21452 target = &(scripts[asscreenscripts[id]]);
21453 break;
21454 }
21455 case 9: //itemsprite
21456 {
21457 int32_t id = assignscript_dlg[37].d1;
21458 if(id < 0 || asitemspritescripts[id] == "<none>" || asitemspritescripts[id].at(0) == '-') break;
21459 target = &(scripts[asitemspritescripts[id]]);
21460 break;
21461 }
21462 case 10: //combo
21463 {
21464 int32_t id = assignscript_dlg[40].d1;
21465 if(id < 0 || ascomboscripts[id] == "<none>" || ascomboscripts[id].at(0) == '-') break;
21466 target = &(scripts[ascomboscripts[id]]);
21467 break;
21468 }
21469 case 11: //generic
21470 {
21471 int32_t id = assignscript_dlg[46].d1;
21472 if(id < 0 || asgenericscripts[id] == "<none>" || asgenericscripts[id].at(0) == '-') break;
21473 target = &(scripts[asgenericscripts[id]]);
21474 break;
21475 }
21476 case 12: //subscreen
21477 {
21478 int32_t id = assignscript_dlg[49].d1;
21479 if(id < 0 || assubscreenscripts[id] == "<none>" || assubscreenscripts[id].at(0) == '-') break;
21480 target = &(scripts[assubscreenscripts[id]]);
21481 break;
21482 }
21483 }
21484 if(target)
21485 showScriptInfo(&target->meta);
21486 break;
21487 }
21488
21489 case 44:
21490 //Clear, clear slots of current type- after a confirmation.
21491 {
21492 doClearSlots(&slotflags);
21493 break;
21494 }
21495 }
21496 }
21497
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(assign_mode == 2) //Smart Assign
21498 {
21499 //For global/hero scripts, match slot names if unoccupied
21500 smart_slot_named(scripts, asglobalscripts, globalmap, global_slotnames, 1, NUMSCRIPTGLOBAL);
21501 smart_slot_named(scripts, asplayerscripts, playermap, player_slotnames, 0, NUMSCRIPTHERO-1);
21502 //For other scripts, assign all un-assigned scripts
21503 smart_slot_type(scripts, asffcscripts, ffcmap, NUMSCRIPTFFC-1);
21504 smart_slot_type(scripts, asitemscripts, itemmap, NUMSCRIPTITEM-1);
21505 smart_slot_type(scripts, asnpcscripts, npcmap, NUMSCRIPTGUYS-1);
21506 smart_slot_type(scripts, aslweaponscripts, lwpnmap, NUMSCRIPTWEAPONS-1);
21507 smart_slot_type(scripts, aseweaponscripts, ewpnmap, NUMSCRIPTWEAPONS-1);
21508 smart_slot_type(scripts, asscreenscripts, screenmap, NUMSCRIPTSCREEN-1);
21509 smart_slot_type(scripts, asdmapscripts, dmapmap, NUMSCRIPTSDMAP-1);
21510 smart_slot_type(scripts, asitemspritescripts, itemspritemap, NUMSCRIPTSITEMSPRITE-1);
21511 smart_slot_type(scripts, ascomboscripts, comboscriptmap, NUMSCRIPTSCOMBODATA-1);
21512 smart_slot_type(scripts, asgenericscripts, genericmap, NUMSCRIPTSGENERIC-1);
21513 smart_slot_type(scripts, assubscreenscripts, subscreenmap, NUMSCRIPTSSUBSCREEN-1);
21514 }
21515 auto_do_slots:
21516 6 doslots_log_output = (assignscript_dlg[13].flags == D_SELECTED);
21517 6 doslots_comment_output = (assignscript_dlg[51].flags == D_SELECTED);
21518 6 doslot_scripts = &scripts;
21519 //OK
21520 {
21521
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(doslots_log_output)
21522 {
21523 string outstr;
21524 write_script(zasm, outstr, doslots_comment_output, doslot_scripts);
21525 safe_al_trace(outstr);
21526 }
21527 6 auto start_assign_time = std::chrono::steady_clock::now();
21528 6 string zasm_str;
21529
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 write_script(zasm, zasm_str, false, nullptr);
21530
21531 6 std::vector<ffscript> zasm;
21532
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(parse_script_string(zasm, zasm_str, false))
21533 goto exit_do_slots;
21534
21535 6 zasm_scripts.clear();
21536
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 zasm_scripts.emplace_back(std::make_shared<zasm_script>(std::move(zasm)));
21537
21538
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!handle_slot_map(ffcmap, 1, ffscripts))
21539 goto exit_do_slots;
21540
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!handle_slot_map(globalmap, 0, globalscripts))
21541 goto exit_do_slots;
21542
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!handle_slot_map(itemmap, 1, itemscripts))
21543 goto exit_do_slots;
21544
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!handle_slot_map(npcmap, 1, guyscripts))
21545 goto exit_do_slots;
21546
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!handle_slot_map(lwpnmap, 1, lwpnscripts))
21547 goto exit_do_slots;
21548
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!handle_slot_map(ewpnmap, 1, ewpnscripts))
21549 goto exit_do_slots;
21550
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!handle_slot_map(playermap, 1, playerscripts))
21551 goto exit_do_slots;
21552
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!handle_slot_map(dmapmap, 1, dmapscripts))
21553 goto exit_do_slots;
21554
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!handle_slot_map(screenmap, 1, screenscripts))
21555 goto exit_do_slots;
21556
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!handle_slot_map(itemspritemap, 1, itemspritescripts))
21557 goto exit_do_slots;
21558
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!handle_slot_map(comboscriptmap, 1, comboscripts))
21559 goto exit_do_slots;
21560
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!handle_slot_map(genericmap, 1, genericscripts))
21561 goto exit_do_slots;
21562
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!handle_slot_map(subscreenmap, 1, subscreenscripts))
21563 goto exit_do_slots;
21564
21565 6 auto end_assign_time = std::chrono::steady_clock::now();
21566
3/6
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
6 int compile_time_ms = std::chrono::duration_cast<std::chrono::milliseconds>(end_assign_time - start_assign_time).count();
21567
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 al_trace("Assign Slots took %d ms\n", compile_time_ms);
21568 6 char buf[256] = {0};
21569 12 sprintf(buf, "ZScripts successfully loaded into script slots"
21570 6 "\nAssign Slots took %d ms", compile_time_ms);
21571
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 compile_finish_sample = vbound(zc_get_config("Compiler","compile_finish_sample",20),0,255);
21572
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 compile_audio_volume = vbound(zc_get_config("Compiler","compile_audio_volume",200),0,255);
21573
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if ( compile_finish_sample > 0 )
21574 {
21575
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(sfxdat)
21576 sfx_voice[compile_finish_sample]=allocate_voice((SAMPLE*)sfxdata[compile_finish_sample].dat);
21577
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 else sfx_voice[compile_finish_sample]=allocate_voice(&customsfxdata[compile_finish_sample]);
21578
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 voice_set_volume(sfx_voice[compile_finish_sample], compile_audio_volume);
21579
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 voice_start(sfx_voice[compile_finish_sample]);
21580 6 }
21581
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(!assign_mode)
21582 InfoDialog("Slots Assigned",buf).show();
21583
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if ( compile_finish_sample > 0 )
21584 {
21585
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(sfx_voice[compile_finish_sample]!=-1)
21586 {
21587
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 deallocate_voice(sfx_voice[compile_finish_sample]);
21588 6 sfx_voice[compile_finish_sample]=-1;
21589 6 }
21590 6 }
21591
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 build_biffs_list();
21592
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 build_biitems_list();
21593 6 retval = true;
21594 6 goto exit_do_slots;
21595
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 }
21596 exit_do_slots:
21597 6 doslot_scripts = nullptr;
21598 6 popup_zqdialog_end();
21599 6 return retval;
21600 }
21601
21602 static char slottype_str_buf[32];
21603
21604 const char *slottype_list(int32_t index, int32_t *list_size)
21605 {
21606 if(index >= 0)
21607 {
21608 bound(index,0,num_types-1);
21609
21610 switch(index)
21611 {
21612 case type_ffc:
21613 strcpy(slottype_str_buf, "FFC");
21614 break;
21615 case type_global:
21616 strcpy(slottype_str_buf, "Global");
21617 break;
21618 case type_itemdata:
21619 strcpy(slottype_str_buf, "Item");
21620 break;
21621 case type_npc:
21622 strcpy(slottype_str_buf, "NPC");
21623 break;
21624 case type_lweapon:
21625 strcpy(slottype_str_buf, "LWeapon");
21626 break;
21627 case type_eweapon:
21628 strcpy(slottype_str_buf, "EWeapon");
21629 break;
21630 case type_hero:
21631 strcpy(slottype_str_buf, "Hero");
21632 break;
21633 case type_dmap:
21634 strcpy(slottype_str_buf, "DMap");
21635 break;
21636 case type_screen:
21637 strcpy(slottype_str_buf, "Screen");
21638 break;
21639 case type_itemsprite:
21640 strcpy(slottype_str_buf, "ItemSprite");
21641 break;
21642 case type_combo:
21643 strcpy(slottype_str_buf, "Combo");
21644 break;
21645 case type_generic:
21646 strcpy(slottype_str_buf, "Generic");
21647 break;
21648 case type_subscreen:
21649 strcpy(slottype_str_buf, "Subscreen");
21650 break;
21651 }
21652
21653 return slottype_str_buf;
21654 }
21655 *list_size = 11;
21656 return NULL;
21657 }
21658 12 static ListData slottype_sel_list(slottype_list, &font);
21659
21660 static DIALOG clearslots_dlg[] =
21661 {
21662 12 { jwin_win_proc, 0, 0, 200, 159, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Clear Slots", NULL, NULL },
21663 12 { jwin_button_proc, 35, 132, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Confirm", NULL, NULL },
21664 12 { jwin_button_proc, 104, 132, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
21665 12 { jwin_droplist_proc, 50, 28+16, 70, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, (void *) &slottype_sel_list, NULL, NULL },
21666 12 { jwin_radio_proc, 40, 34+00, 81, 9, vc(14), vc(1), 0, D_SELECTED, 0, 0, (void *) "Clear Script Type:", NULL, NULL },
21667 12 { jwin_radio_proc, 40, 34+32, 81, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear Missing (--) Slots", NULL, NULL },
21668 12 { jwin_radio_proc, 40, 34+80, 81, 9, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear All", NULL, NULL },
21669 12 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
21670 12 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
21671 };
21672
21673 void doClearSlots(byte* flags)
21674 {
21675 //{ Setup
21676 clearslots_dlg[0].dp2=get_zc_font(font_lfont);
21677 clearslots_dlg[3].d1 = get_selected_tab((TABPANEL*)assignscript_dlg[1].dp); //Default to current tab's type
21678 clearslots_dlg[4].flags |= D_SELECTED;
21679 clearslots_dlg[5].flags &= ~D_SELECTED;
21680 clearslots_dlg[6].flags &= ~D_SELECTED;
21681 if(((*flags) & SLOTMSGFLAG_MISSING) == 0)
21682 clearslots_dlg[5].flags |= D_DISABLED;
21683 else
21684 clearslots_dlg[5].flags &= ~D_DISABLED;
21685 //}
21686
21687 large_dialog(clearslots_dlg);
21688
21689 if(do_zqdialog(clearslots_dlg,2)==1)
21690 {
21691 int32_t q = 3;
21692 while((clearslots_dlg[++q].flags & D_SELECTED) == 0);
21693 switch(q)
21694 {
21695 case 4: //Clear type
21696 {
21697 clearAllSlots(clearslots_dlg[3].d1);
21698 break;
21699 }
21700 case 5: //Clear Missing
21701 {
21702 for(int32_t q = 0; q <= 10; ++q)
21703 clearAllSlots(q,SLOTMSGFLAG_MISSING);
21704 break;
21705 }
21706 case 6: //Clear ALL
21707 {
21708 for(int32_t q = 0; q <= 10; ++q)
21709 clearAllSlots(q);
21710 break;
21711 }
21712 }
21713 }
21714 }
21715
21716 static DIALOG exportzasm_dlg[] =
21717 {
21718 12 { jwin_win_proc, 0, 0, 200, 159, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Export ZASM", NULL, NULL },
21719 12 { jwin_button_proc, 35, 132, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Confirm", NULL, NULL },
21720 12 { jwin_button_proc, 104, 132, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
21721 12 { jwin_droplist_proc, 50, 28+16, 100, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, D_EXIT, 0, 0, (void *) &slottype_sel_list, NULL, NULL },
21722 12 { jwin_droplist_proc, 50, 28+48, 100, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
21723 12 { jwin_text_proc, 50, 28+8, 16, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Script Type:", NULL, NULL },
21724 12 { jwin_text_proc, 50, 28+40, 16, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Script Slot:", NULL, NULL },
21725 12 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
21726 };
21727
21728 static DIALOG importzasm_dlg[] =
21729 {
21730 12 { jwin_win_proc, 0, 0, 200, 159, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Import ZASM", NULL, NULL },
21731 12 { jwin_button_proc, 35, 132, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "Confirm", NULL, NULL },
21732 12 { jwin_button_proc, 104, 132, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
21733 12 { jwin_droplist_proc, 50, 28+16, 100, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, D_EXIT, 0, 0, (void *) &slottype_sel_list, NULL, NULL },
21734 12 { jwin_droplist_proc, 50, 28+48, 100, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 0, 0, NULL, NULL, NULL },
21735 // 5
21736 12 { jwin_text_proc, 50, 28+8, 16, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Script Type:", NULL, NULL },
21737 12 { jwin_text_proc, 50, 28+40, 16, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Script Slot:", NULL, NULL },
21738 12 { jwin_text_proc, 50, 28+72, 16, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Script Name:", NULL, NULL },
21739 12 { jwin_edit_proc, 50, 28+80, 100, 16, jwin_pal[jcTEXTFG], jwin_pal[jcTEXTBG], 0, 0, 19, 0, NULL, NULL, NULL },
21740
21741 12 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
21742 };
21743 extern ListData itemscript_list;
21744 extern ListData itemspritescript_list;
21745 extern ListData lweaponscript_list;
21746 extern ListData npcscript_list;
21747 extern ListData eweaponscript_list;
21748 extern ListData comboscript_list;
21749
21750 8 void center_zscript_dialogs()
21751 {
21752 8 jwin_center_dialog(exportzasm_dlg);
21753 8 jwin_center_dialog(importzasm_dlg);
21754 8 jwin_center_dialog(clearslots_dlg);
21755 8 }
21756
21757 // array of voices, one for each sfx sample in the data file
21758 // 0+ = voice #
21759 // -1 = voice not allocated
21760 int32_t sfx_voice[WAV_COUNT];
21761
21762 void Z_init_sound()
21763 {
21764 for(int32_t i=0; i<WAV_COUNT; i++)
21765 sfx_voice[i]=-1;
21766
21767 // master_volume(digi_volume,midi_volume);
21768 }
21769
21770 // returns number of voices currently allocated
21771 int32_t sfx_count()
21772 {
21773 int32_t c=0;
21774
21775 for(int32_t i=0; i<WAV_COUNT; i++)
21776 if(sfx_voice[i]!=-1)
21777 ++c;
21778
21779 return c;
21780 }
21781
21782 // clean up finished samples
21783 void sfx_cleanup()
21784 {
21785 for(int32_t i=0; i<WAV_COUNT; i++)
21786 if(sfx_voice[i]!=-1 && voice_get_position(sfx_voice[i])<0)
21787 {
21788 deallocate_voice(sfx_voice[i]);
21789 sfx_voice[i]=-1;
21790 }
21791 }
21792
21793 // allocates a voice for the sample "wav_index" (index into zelda.dat)
21794 // if a voice is already allocated (and/or playing), then it just returns true
21795 // Returns true: voice is allocated
21796 // false: unsuccessful
21797 SAMPLE templist[WAV_COUNT];
21798
21799 bool sfx_init(int32_t index)
21800 {
21801 // check index
21802 if(index<1 || index>=WAV_COUNT)
21803 return false;
21804
21805 if(sfx_voice[index]==-1)
21806 {
21807 sfx_voice[index]=allocate_voice(&templist[index]);
21808 }
21809
21810 return sfx_voice[index] != -1;
21811 }
21812
21813 // plays an sfx sample
21814 void sfx(int32_t index,int32_t pan,bool loop,bool restart,int32_t vol,int32_t freq)
21815 {
21816 if(!sfx_init(index))
21817 return;
21818
21819 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
21820 voice_set_pan(sfx_voice[index],pan);
21821
21822 int32_t pos = voice_get_position(sfx_voice[index]);
21823
21824 if(restart) voice_set_position(sfx_voice[index],0);
21825
21826 if(pos<=0)
21827 voice_start(sfx_voice[index]);
21828 }
21829
21830 // start it (in loop mode) if it's not already playing,
21831 // otherwise just leave it in its current position
21832 void cont_sfx(int32_t index)
21833 {
21834 if(!sfx_init(index))
21835 return;
21836
21837 if(voice_get_position(sfx_voice[index])<=0)
21838 {
21839 voice_set_position(sfx_voice[index],0);
21840 voice_set_playmode(sfx_voice[index],PLAYMODE_LOOP);
21841 voice_start(sfx_voice[index]);
21842 }
21843 }
21844
21845 // adjust parameters while playing
21846 void adjust_sfx(int32_t index,int32_t pan,bool loop)
21847 {
21848 if(index<0 || index>=WAV_COUNT || sfx_voice[index]==-1)
21849 return;
21850
21851 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
21852 voice_set_pan(sfx_voice[index],pan);
21853 }
21854
21855 // pauses a voice
21856 void pause_sfx(int32_t index)
21857 {
21858 if(index>=0 && index<WAV_COUNT && sfx_voice[index]!=-1)
21859 voice_stop(sfx_voice[index]);
21860 }
21861
21862 // resumes a voice
21863 void resume_sfx(int32_t index)
21864 {
21865 if(index>=0 && index<WAV_COUNT && sfx_voice[index]!=-1)
21866 voice_start(sfx_voice[index]);
21867 }
21868
21869 // pauses all active voices
21870 void pause_all_sfx()
21871 {
21872 for(int32_t i=0; i<WAV_COUNT; i++)
21873 if(sfx_voice[i]!=-1)
21874 voice_stop(sfx_voice[i]);
21875 }
21876
21877 // resumes all paused voices
21878 void resume_all_sfx()
21879 {
21880 for(int32_t i=0; i<WAV_COUNT; i++)
21881 if(sfx_voice[i]!=-1)
21882 voice_start(sfx_voice[i]);
21883 }
21884
21885 // stops an sfx and deallocates the voice
21886 void stop_sfx(int32_t index)
21887 {
21888 if(index<0 || index>=WAV_COUNT)
21889 return;
21890
21891 if(sfx_voice[index]!=-1)
21892 {
21893 deallocate_voice(sfx_voice[index]);
21894 sfx_voice[index]=-1;
21895 }
21896 }
21897
21898 void kill_sfx()
21899 {
21900 for(int32_t i=0; i<WAV_COUNT; i++)
21901 if(sfx_voice[i]!=-1)
21902 {
21903 deallocate_voice(sfx_voice[i]);
21904 sfx_voice[i]=-1;
21905 }
21906 }
21907
21908 int32_t pan(int32_t x)
21909 {
21910 return 128;
21911 /*switch(pan_style)
21912 {
21913 case 0: return 128;
21914 case 1: return vbound((x>>1)+68,0,255);
21915 case 2: return vbound(((x*3)>>2)+36,0,255);
21916 }
21917 return vbound(x,0,255);*/
21918 }
21919
21920
21921 void change_sfx(SAMPLE *sfx1, SAMPLE *sfx2)
21922 {
21923 sfx1->bits = sfx2->bits;
21924 sfx1->stereo = sfx2->stereo;
21925 sfx1->freq = sfx2->freq;
21926 sfx1->priority = sfx2->priority;
21927 sfx1->len = sfx2->len;
21928 sfx1->loop_start = sfx2->loop_start;
21929 sfx1->loop_end = sfx2->loop_end;
21930 sfx1->param = sfx2->param;
21931
21932 if(sfx1->data != NULL)
21933 {
21934 free(sfx1->data);
21935 }
21936
21937 if(sfx2->data == NULL)
21938 sfx1->data = NULL;
21939 else
21940 {
21941 // When quests are saved and loaded, data is written in words.
21942 // If the last byte is dropped, it'll cause the sound to end with
21943 // a click. It could simply be extended and padded with 0, but
21944 // that causes compatibility issues... So we'll cut off
21945 // the last byte and decrease the length.
21946
21947 int32_t len = (sfx1->bits==8?1:2)*(sfx1->stereo == 0 ? 1 : 2)*sfx1->len;
21948
21949 while(len%sizeof(word))
21950 {
21951 // sizeof(word) should be 2, so this doesn't really need
21952 // to be a loop, but what the heck.
21953 sfx1->len--;
21954 len = (sfx1->bits==8?1:2)*(sfx1->stereo == 0 ? 1 : 2)*sfx1->len;
21955 }
21956
21957 sfx1->data = malloc(len);
21958 memcpy(sfx1->data, sfx2->data, len);
21959 }
21960 }
21961
21962 bool confirmBox(const char *m1, const char *m2, const char *m3)
21963 {
21964 if(!m3)
21965 {
21966 if(!m2) m2 = "Are you sure?";
21967 else m3 = "Are you sure?";
21968 }
21969 return jwin_alert("Confirmation", m1, m2, m3, "Yes", "No", 'y', 'n', get_zc_font(font_lfont)) == 1;
21970 }
21971
21972 int32_t onSelectSFX()
21973 {
21974 SFXListerDialog(0).show();
21975 refresh(rMAP+rCOMBOS);
21976 return D_O_K;
21977 }
21978
21979 bool saveWAV(int32_t slot, const char *filename)
21980 {
21981 if (slot < 1 || slot >= 511 )
21982 return false;
21983
21984 if (customsfxdata[slot].data == NULL)
21985 return false;
21986
21987 std::ofstream ofs(filename, std::ios::binary);
21988 if (!ofs)
21989 return false;
21990 ofs.write("RIFF",4);
21991 uint32_t samplerate = customsfxdata[slot].freq;
21992 uint16_t channels = customsfxdata[slot].stereo ? 2 : 1;
21993 uint32_t datalen = customsfxdata[slot].len*channels*customsfxdata[slot].bits / 8;
21994 uint32_t size = 36 + datalen;
21995 ofs.write((char *)&size, 4);
21996 ofs.write("WAVE", 4);
21997 ofs.write("fmt ", 4);
21998 uint32_t fmtlen = 16;
21999 ofs.write((char *)&fmtlen, 4);
22000 uint16_t type = 1;
22001 ofs.write((char *)&type, 2);
22002 ofs.write((char *)&channels, 2);
22003 ofs.write((char *)&samplerate, 4);
22004 uint32_t bytespersec = samplerate*channels*customsfxdata[slot].bits / 8;
22005 ofs.write((char *)&bytespersec, 4);
22006 uint16_t blockalign = channels*customsfxdata[slot].bits / 8;
22007 ofs.write((char *)&blockalign, 2);
22008 uint16_t bitspersample = customsfxdata[slot].bits;
22009 ofs.write((char *)&bitspersample, 2);
22010 ofs.write("data", 4);
22011 ofs.write((char *)&datalen, 4);
22012 if (bitspersample == 8)
22013 {
22014 for (int32_t i = 0; i < (int32_t)customsfxdata[slot].len*channels; i++)
22015 {
22016 char data = ((char *)customsfxdata[slot].data)[i];
22017 data ^= 0x80;
22018 ofs.write(&data, 1);
22019 }
22020 }
22021 else if (bitspersample == 16)
22022 {
22023 for (int32_t i = 0; i < (int32_t)customsfxdata[slot].len*channels; i++)
22024 {
22025 uint16_t data = ((uint16_t *)customsfxdata[slot].data)[i];
22026 data ^= 0x8000;
22027 ofs.write((char *)&data, 2);
22028 }
22029 }
22030 else
22031 return false;
22032 return !!ofs;
22033 }
22034
22035 int32_t onEditSFX(int32_t index)
22036 {
22037 call_sfxdata_dialog(index);
22038 return D_O_K;
22039 }
22040
22041 int32_t onMapStyles()
22042 {
22043 call_mapstyles_dialog();
22044 return D_O_K;
22045 }
22046
22047 int32_t d_misccolors_old_proc(int32_t msg,DIALOG *d,int32_t c)
22048 {
22049 //these are here to bypass compiler warnings about unused arguments
22050 c=c;
22051
22052 if(msg==MSG_DRAW)
22053 {
22054 textout_ex(screen,font,"0123456789ABCDEF",d->x+8,d->y,d->fg,d->bg);
22055 textout_ex(screen,font,"0",d->x,d->y+8,d->fg,d->bg);
22056 textout_ex(screen,font,"1",d->x,d->y+16,d->fg,d->bg);
22057 textout_ex(screen,font,"5",d->x,d->y+24,d->fg,d->bg);
22058
22059 for(int32_t i=0; i<32; i++)
22060 {
22061 int32_t px2 = d->x+((i&15)<<3)+8;
22062 int32_t py2 = d->y+((i>>4)<<3)+8;
22063 rectfill(screen,px2,py2,px2+7,py2+7,i);
22064 }
22065
22066 for(int32_t i=0; i<16; i++)
22067 {
22068 int32_t px2 = d->x+(i<<3)+8;
22069 rectfill(screen,px2,d->y+24,px2+7,d->y+31,i+80);
22070 }
22071 }
22072
22073 return D_O_K;
22074 }
22075
22076 int32_t hexclicked=-1;
22077
22078 int32_t d_misccolors_hexedit_proc(int32_t msg,DIALOG *d,int32_t c)
22079 {
22080 switch(msg)
22081 {
22082 case MSG_GOTFOCUS:
22083 hexclicked=((int32_t)(size_t)(d->dp3))+20;
22084 break;
22085
22086 case MSG_LOSTFOCUS:
22087 hexclicked=-1;
22088 break;
22089 }
22090
22091 return d_hexedit_proc(msg,d,c);
22092 }
22093
22094
22095 int32_t d_misccolors_proc(int32_t msg,DIALOG *d,int32_t c);
22096
22097 static int32_t misccolor1_list[] =
22098 {
22099 // dialog control number
22100 4, 5, 6, 7, 8, 20, 21, 22, 23, 24, 36, 37, 38, 39, 40, -1
22101 };
22102
22103 static int32_t misccolor2_list[] =
22104 {
22105 // dialog control number
22106 9, 10, 11, 12, 13, 25, 26, 27, 28, 29, 41, 42, 43, 44, 45, -1
22107 };
22108
22109 static int32_t misccolor3_list[] =
22110 {
22111 // dialog control number
22112 14, 15, 16, 17, 18, 30, 31, 32, 33, 34, 46, 47, 48, 49, 50, -1
22113 };
22114
22115 static int32_t misccolor4_list[] =
22116 {
22117 19, 35, 51, 54, 55, 56, -1
22118 };
22119
22120 static TABPANEL misccolor_tabs[] =
22121 {
22122 // (text)
22123 { (char *)"1", D_SELECTED, misccolor1_list, 0, NULL },
22124 { (char *)"2", 0, misccolor2_list, 0, NULL },
22125 { (char *)"3", 0, misccolor3_list, 0, NULL },
22126 { (char *)"4", 0, misccolor4_list, 0, NULL },
22127 { NULL, 0, NULL, 0, NULL }
22128 };
22129
22130 int32_t d_misccolors_tab_proc(int32_t msg,DIALOG *d,int32_t c);
22131
22132 static DIALOG misccolors_dlg[] =
22133 {
22134 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
22135 12 { jwin_win_proc, 2, 21, 316, 197-23, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Misc Colors", NULL, NULL },
22136 // { jwin_frame_proc, 98-84+1+2, 52+8-6+4, 132, 100, vc(15), vc(1), 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
22137 12 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
22138 12 { d_misccolors_proc, 92-84+1+2, 44+8-6+4, 128+8, 96+8, vc(9), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
22139 //3
22140 12 { d_misccolors_tab_proc, 150+14-2+10-15, 60-14, 150-10+15, 144-20-10, jwin_pal[jcBOXFG], jwin_pal[jcBOX], 0, 0, 0, 0, (void *) misccolor_tabs, NULL, (void *)misccolors_dlg },
22141 //4
22142 12 { jwin_text_proc, 215-25-12-15, 76-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Text:", NULL, NULL },
22143 12 { jwin_text_proc, 215-25-12-15, 94-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Caption:", NULL, NULL },
22144 12 { jwin_text_proc, 215-25-12-15, 112-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Overworld Minmap:", NULL, NULL },
22145 12 { jwin_text_proc, 215-25-12-15, 130-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Minimap Background:", NULL, NULL },
22146 12 { jwin_text_proc, 215-25-12-15, 148-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Minimap Foreground 1:", NULL, NULL },
22147 12 { jwin_text_proc, 215-25-12-15, 76-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Minimap Foreground 2:", NULL, NULL },
22148 12 { jwin_text_proc, 215-25-12-15, 94-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "BS Minimap Dark:", NULL, NULL },
22149 12 { jwin_text_proc, 215-25-12-15, 112-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "BS Minimap Goal:", NULL, NULL },
22150 12 { jwin_text_proc, 215-25-12-15, 130-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Compass Mark (Light):", NULL, NULL },
22151 12 { jwin_text_proc, 215-25-12-15, 148-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Compass Mark (Dark):", NULL, NULL },
22152 12 { jwin_text_proc, 215-25-12-15, 76-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Subscreen Background:", NULL, NULL },
22153 12 { jwin_text_proc, 215-25-12-15, 94-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Subscreen Shadow:", NULL, NULL },
22154 12 { jwin_text_proc, 215-25-12-15, 112-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Triforce Frame:", NULL, NULL },
22155 12 { jwin_text_proc, 215-25-12-15, 130-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Big Map Background:", NULL, NULL },
22156 12 { jwin_text_proc, 215-25-12-15, 148-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Big Map Foreground:", NULL, NULL },
22157 12 { jwin_text_proc, 215-25-12-15, 76-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Hero's Position:", NULL, NULL },
22158
22159 //20
22160 12 { d_misccolors_hexedit_proc, 294-25+14+2, 76-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)0, },
22161 12 { d_misccolors_hexedit_proc, 294-25+14+2, 94-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)1, },
22162 12 { d_misccolors_hexedit_proc, 294-25+14+2, 112-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)2, },
22163 12 { d_misccolors_hexedit_proc, 294-25+14+2, 130-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)3, },
22164 12 { d_misccolors_hexedit_proc, 294-25+14+2, 148-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)4, },
22165 12 { d_misccolors_hexedit_proc, 294-25+14+2, 76-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)5, },
22166 12 { d_misccolors_hexedit_proc, 294-25+14+2, 94-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)6, },
22167 12 { d_misccolors_hexedit_proc, 294-25+14+2, 112-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)7, },
22168 12 { d_misccolors_hexedit_proc, 294-25+14+2, 130-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)8, },
22169 12 { d_misccolors_hexedit_proc, 294-25+14+2, 148-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)9, },
22170 12 { d_misccolors_hexedit_proc, 294-25+14+2, 76-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)10, },
22171 12 { d_misccolors_hexedit_proc, 294-25+14+2, 94-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)11, },
22172 12 { d_misccolors_hexedit_proc, 294-25+14+2, 112-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)12, },
22173 12 { d_misccolors_hexedit_proc, 294-25+14+2, 130-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)13, },
22174 12 { d_misccolors_hexedit_proc, 294-25+14+2, 148-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)14, },
22175 12 { d_misccolors_hexedit_proc, 294-25+14+2, 76-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)15, },
22176
22177 //36
22178 12 { jwin_text_proc, 283-25+14+2, 76-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
22179 12 { jwin_text_proc, 283-25+14+2, 94-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
22180 12 { jwin_text_proc, 283-25+14+2, 112-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
22181 12 { jwin_text_proc, 283-25+14+2, 130-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
22182 12 { jwin_text_proc, 283-25+14+2, 148-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
22183 12 { jwin_text_proc, 283-25+14+2, 76-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
22184 12 { jwin_text_proc, 283-25+14+2, 94-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
22185 12 { jwin_text_proc, 283-25+14+2, 112-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
22186 12 { jwin_text_proc, 283-25+14+2, 130-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
22187 12 { jwin_text_proc, 283-25+14+2, 148-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
22188 12 { jwin_text_proc, 283-25+14+2, 76-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
22189 12 { jwin_text_proc, 283-25+14+2, 94-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
22190 12 { jwin_text_proc, 283-25+14+2, 112-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
22191 12 { jwin_text_proc, 283-25+14+2, 130-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
22192 12 { jwin_text_proc, 283-25+14+2, 148-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
22193 12 { jwin_text_proc, 283-25+14+2, 76-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
22194
22195 //52
22196 12 { jwin_button_proc, 90, 190-20, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
22197 12 { jwin_button_proc, 170, 190-20, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
22198 12 { jwin_text_proc, 215-25-12-15, 94-4, 0, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Message Text:", NULL, NULL },
22199 12 { d_misccolors_hexedit_proc, 294-25+14+2, 94-8, 21, 16, vc(11), vc(1), 0, 0, 2, 0, NULL, NULL, (void *)35, },
22200 12 { jwin_text_proc, 283-25+14+2, 94-4, 0, 8, vc(11), vc(1), 0, 0, 2, 0, (void *) "0x", NULL, NULL },
22201 12 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
22202 };
22203
22204 int32_t d_misccolors_tab_proc(int32_t msg,DIALOG *d,int32_t c)
22205 {
22206
22207 switch(msg)
22208 {
22209 case MSG_WANTFOCUS:
22210 return D_WANTFOCUS;
22211 break;
22212 }
22213
22214 return jwin_tab_proc(msg,d,c);
22215 }
22216
22217
22218 int32_t d_misccolors_proc(int32_t msg,DIALOG *d,int32_t c)
22219 {
22220 //these are here to bypass compiler warnings about unused arguments
22221 c=c;
22222 int32_t mul=12;
22223
22224 switch(msg)
22225 {
22226 case MSG_CLICK:
22227 if(hexclicked!=-1)
22228 {
22229 int32_t color_col=vbound(((gui_mouse_x()-d->x-8)/mul),0,15);
22230 int32_t color_row=vbound(((gui_mouse_y()-d->y-10)/mul),0,11);
22231 sprintf((char*)misccolors_dlg[hexclicked].dp,"%X%X",color_row,color_col);
22232 object_message(misccolors_dlg+hexclicked,MSG_DRAW,0);
22233 }
22234
22235 break;
22236
22237 case MSG_DRAW:
22238 for(int32_t i=0; i<10; i++)
22239 {
22240 textprintf_centre_ex(screen,font,d->x+8+4+(i*mul),d->y,jwin_pal[jcBOXFG],jwin_pal[jcBOX], "%d", i);
22241 }
22242
22243 for(int32_t i=0; i<6; i++)
22244 {
22245 textprintf_centre_ex(screen,font,d->x+8+4+((10+i)*mul),d->y,jwin_pal[jcBOXFG],jwin_pal[jcBOX], "%c", i+'A');
22246 }
22247
22248 for(int32_t i=0; i<10; i++)
22249 {
22250 textprintf_right_ex(screen,font,d->x+6,d->y+(i*mul)+10,jwin_pal[jcBOXFG],jwin_pal[jcBOX], "%d", i);
22251 }
22252
22253 for(int32_t i=0; i<2; i++)
22254 {
22255 textprintf_right_ex(screen,font,d->x+6,d->y+((i+10)*mul)+10,jwin_pal[jcBOXFG],jwin_pal[jcBOX], "%c", i+'A');
22256 }
22257
22258 jwin_draw_frame(screen,d->x+6,d->y+8,int32_t(132*1.5)-2,int32_t(100*1.5)-2,FR_DEEP);
22259
22260 for(int32_t i=0; i<192; i++)
22261 {
22262 int32_t px2 = d->x+int32_t(((i&15)<<3)*1.5)+8;
22263 int32_t py2 = d->y+int32_t(((i>>4)<<3)*1.5)+8+2;
22264 rectfill(screen,px2,py2,px2+(mul-1),py2+(mul-1),i);
22265 }
22266
22267 break;
22268 }
22269
22270 return D_O_K;
22271 }
22272
22273
22274 int32_t onMiscColors()
22275 {
22276 char buf[17][3];
22277 byte *si = &(QMisc.colors.text);
22278 misccolors_dlg[0].dp2=get_zc_font(font_lfont);
22279
22280 for(int32_t i=0; i<16; i++)
22281 {
22282 sprintf(buf[i],"%02X",*(si++));
22283 sprintf(buf[16], "%02X", QMisc.colors.msgtext);
22284 misccolors_dlg[i+20].dp = buf[i];
22285 misccolors_dlg[55].dp = buf[16];
22286 }
22287
22288 large_dialog(misccolors_dlg);
22289
22290 if(do_zqdialog(misccolors_dlg,0)==52)
22291 {
22292 saved=false;
22293 si = &(QMisc.colors.text);
22294
22295 for(int32_t i=0; i<16; i++)
22296 {
22297 *si = zc_xtoi(buf[i]);
22298 ++si;
22299 }
22300
22301 QMisc.colors.msgtext = zc_xtoi(buf[16]);
22302 }
22303
22304 return D_O_K;
22305 }
22306
22307 // **** Palette cycling ****
22308
22309 static int32_t palclk[3];
22310 static int32_t palpos[3];
22311
22312 33 void reset_pal_cycling()
22313 {
22314
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 33 times.
132 for(int32_t i=0; i<3; i++)
22315 99 palclk[i]=palpos[i]=0;
22316 33 }
22317
22318 void cycle_palette()
22319 {
22320 if(!get_qr(qr_FADE))
22321 return;
22322
22323 int32_t level = Map.CurrScr()->color;
22324 bool refreshpal = false;
22325
22326 for(int32_t i=0; i<3; i++)
22327 {
22328 palcycle c = QMisc.cycles[level][i];
22329
22330 if(c.count&0xF0)
22331 {
22332 if(++palclk[i] >= c.speed)
22333 {
22334 palclk[i]=0;
22335
22336 if(++palpos[i] >= (c.count>>4))
22337 palpos[i]=0;
22338
22339 byte *si = colordata + CSET(level*pdLEVEL+poFADE1+1+palpos[i])*3;
22340
22341 si += (c.first&15)*3;
22342
22343 for(int32_t col=c.first&15; col<=(c.count&15); col++)
22344 {
22345 RAMpal[CSET(c.first>>4)+col] = _RGB(si);
22346 si+=3;
22347 }
22348
22349 refreshpal = true;
22350 }
22351 }
22352 }
22353
22354 if(refreshpal)
22355 {
22356 rebuild_trans_table();
22357 zc_set_palette_range(RAMpal,0,192,false);
22358 }
22359 }
22360
22361
22362 void doHelp()
22363 {
22364 do_box_edit(helpstr, "ZQuest Help", true, true);
22365 }
22366
22367 int32_t onHelp()
22368 {
22369 restore_mouse();
22370 doHelp();
22371 return D_O_K;
22372 }
22373
22374 void doZstringshelp()
22375 {
22376 do_box_edit(zstringshelpstr, "ZStrings Help", true, true);
22377 }
22378
22379 int32_t onZstringshelp()
22380 {
22381 restore_mouse();
22382 doZstringshelp();
22383 return D_O_K;
22384 }
22385
22386 static DIALOG layerdata_dlg[] =
22387 {
22388 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
22389 { jwin_win_proc, 16-12, 20+32, 288+1+24, 200+1-32-16, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Layer Data", NULL, NULL },
22390 { jwin_button_proc, 170, 180, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
22391 { jwin_button_proc, 90, 180, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
22392 // 3
22393 { jwin_rtext_proc, 72, 88, 40, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Map:", NULL, NULL },
22394 { jwin_rtext_proc, 72, 88+18, 48, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Screen:", NULL, NULL },
22395 { jwin_rtext_proc, 72, 88+36, 56, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "Transparent:", NULL, NULL },
22396 { jwin_ctext_proc, 89, 76, 8, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "1", NULL, NULL },
22397 { jwin_ctext_proc, 89+40, 76, 8, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "2", NULL, NULL },
22398 { jwin_ctext_proc, 89+80, 76, 8, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "3", NULL, NULL },
22399 { jwin_ctext_proc, 89+120, 76, 8, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "4", NULL, NULL },
22400 { jwin_ctext_proc, 89+160, 76, 8, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "5", NULL, NULL },
22401 { jwin_ctext_proc, 89+200, 76, 8, 8, vc(11), vc(1), 0, 0, 0, 0, (void *) "6", NULL, NULL },
22402
22403 //12
22404 { jwin_edit_proc, 76, 76+8, 32-6, 16, vc(12), vc(1), 0, 0, 3, 0, NULL, NULL, NULL },
22405 { d_hexedit_proc, 76, 76+18+8, 24-3, 16, vc(12), vc(1), 0, 0, 2, 0, NULL, NULL, NULL },
22406 { jwin_check_proc, 76, 76+40+8, 17, 9, vc(12), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
22407
22408 { jwin_edit_proc, 76+40, 76+8, 32-6, 16, vc(12), vc(1), 0, 0, 3, 0, NULL, NULL, NULL },
22409 { d_hexedit_proc, 76+40, 76+18+8, 24-3, 16, vc(12), vc(1), 0, 0, 2, 0, NULL, NULL, NULL },
22410 { jwin_check_proc, 76+40, 76+40+8, 17, 9, vc(12), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
22411
22412 { jwin_edit_proc, 76+80, 76+8, 32-6, 16, vc(12), vc(1), 0, 0, 3, 0, NULL, NULL, NULL },
22413 { d_hexedit_proc, 76+80, 76+18+8, 24-3, 16, vc(12), vc(1), 0, 0, 2, 0, NULL, NULL, NULL },
22414 { jwin_check_proc, 76+80, 76+40+8, 17, 9, vc(12), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
22415
22416 { jwin_edit_proc, 76+120, 76+8, 32-6, 16, vc(12), vc(1), 0, 0, 3, 0, NULL, NULL, NULL },
22417 { d_hexedit_proc, 76+120, 76+18+8, 24-3, 16, vc(12), vc(1), 0, 0, 2, 0, NULL, NULL, NULL },
22418 { jwin_check_proc, 76+120, 76+40+8, 17, 9, vc(12), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
22419
22420 { jwin_edit_proc, 76+160, 76+8, 32-6, 16, vc(12), vc(1), 0, 0, 3, 0, NULL, NULL, NULL },
22421 { d_hexedit_proc, 76+160, 76+18+8, 24-3, 16, vc(12), vc(1), 0, 0, 2, 0, NULL, NULL, NULL },
22422 { jwin_check_proc, 76+160, 76+40+8, 17, 9, vc(12), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
22423
22424 { jwin_edit_proc, 76+200, 76+8, 32-6, 16, vc(12), vc(1), 0, 0, 3, 0, NULL, NULL, NULL },
22425 { d_hexedit_proc, 76+200, 76+18+8, 24-3, 16, vc(12), vc(1), 0, 0, 2, 0, NULL, NULL, NULL },
22426 { jwin_check_proc, 76+200, 76+40+8, 17, 9, vc(12), vc(1), 0, 0, 1, 0, NULL, NULL, NULL },
22427
22428 //30
22429 { jwin_button_proc, 76, 76+40+18+8, 30, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Auto", NULL, NULL },
22430 { jwin_button_proc, 76+40, 76+40+18+8, 30, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Auto", NULL, NULL },
22431 { jwin_button_proc, 76+80, 76+40+18+8, 30, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Auto", NULL, NULL },
22432 { jwin_button_proc, 76+120, 76+40+18+8, 30, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Auto", NULL, NULL },
22433 { jwin_button_proc, 76+160, 76+40+18+8, 30, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Auto", NULL, NULL },
22434 { jwin_button_proc, 76+200, 76+40+18+8, 30, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Auto", NULL, NULL },
22435
22436 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
22437 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
22438
22439 };
22440
22441 int32_t edit_layers(mapscr* tempscr)
22442 {
22443 char buf[6][2][8];
22444 layerdata_dlg[0].dp2 = get_zc_font(font_lfont);
22445
22446 for(int32_t x=0; x<6; x++)
22447 {
22448 sprintf(buf[x][0],"%d",tempscr->layermap[x]);
22449 sprintf(buf[x][1],"%02X",tempscr->layerscreen[x]);
22450 }
22451
22452 for(int32_t x=0; x<6; x++)
22453 {
22454 for(int32_t y=0; y<2; y++)
22455 {
22456 layerdata_dlg[(x*3)+y+12].dp = buf[x][y];
22457 }
22458 }
22459
22460 for(int32_t x=0; x<6; x++)
22461 {
22462 layerdata_dlg[(x*3)+2+12].flags = (tempscr->layeropacity[x]<255) ? D_SELECTED : 0;
22463 }
22464
22465 large_dialog(layerdata_dlg);
22466
22467 int32_t ret=do_zqdialog(layerdata_dlg,0);
22468
22469 if(ret>=2)
22470 {
22471 for(int32_t x=0; x<6; x++)
22472 {
22473
22474 tempscr->layermap[x]=atoi(buf[x][0]);
22475
22476 if(tempscr->layermap[x]>map_count)
22477 {
22478 tempscr->layermap[x]=0;
22479 }
22480
22481 tempscr->layerscreen[x]=zc_xtoi(buf[x][1]);
22482
22483 if(zc_xtoi(buf[x][1])>=MAPSCRS)
22484 {
22485 tempscr->layerscreen[x]=0;
22486 }
22487
22488 // tempscr->layeropacity[x]=layerdata_dlg[(x*9)+8+19].flags & D_SELECTED ? 128:255;
22489 tempscr->layeropacity[x]=layerdata_dlg[(x*3)+2+12].flags & D_SELECTED ? 128:255;
22490 }
22491
22492 // } else if (ret>72&&ret<79) {
22493 // return (ret-72);
22494 }
22495
22496 return ret;
22497 }
22498
22499 static DIALOG autolayer_dlg[] =
22500 {
22501 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
22502 { jwin_win_proc, 64, 32+48, 192+1, 184+1-64, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Autolayer Setup", NULL, NULL },
22503 { jwin_text_proc, 76, 56+48, 136, 8, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map for layer ?: ", NULL, NULL },
22504 { jwin_edit_proc, 212, 56+48, 32, 16, vc(12), vc(1), 0, 0, 3, 0, NULL, NULL, NULL },
22505 { jwin_check_proc, 76, 56+18+48, 153, 8, vc(14), vc(1), 0, D_EXIT, 1, 0, (void *) "Only Blank Screens", NULL, NULL },
22506 { jwin_button_proc, 90, 188-12, 61, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
22507
22508 //5
22509 { jwin_button_proc, 170, 188-12, 61, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
22510 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onHelp, NULL, NULL },
22511 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
22512 { jwin_check_proc, 76, 56+28+48, 153, 8, vc(14), vc(1), 0, D_EXIT, 1, 0, (void *) "Only Blank Layers", NULL, NULL },
22513 { jwin_check_proc, 76, 56+38+48, 153, 8, vc(14), vc(1), 0, D_EXIT, 1, 0, (void *) "Overwrite Layers", NULL, NULL },
22514
22515 //10
22516 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
22517 };
22518 enum
22519 {
22520 autolyr_blankscreens,
22521 autolyr_blanklayers,
22522 autolyr_any
22523 };
22524 void autolayer(mapscr* tempscr, int32_t layer, int32_t al[6][3])
22525 {
22526 char tbuf[80],mlayer[80];
22527 autolayer_dlg[0].dp2=get_zc_font(font_lfont);
22528 sprintf(tbuf, "Map for layer %d: ", layer+1);
22529 autolayer_dlg[1].dp=tbuf;
22530 sprintf(mlayer, "%d", tempscr->layermap[layer]);
22531 autolayer_dlg[2].dp=mlayer;
22532
22533 large_dialog(autolayer_dlg);
22534 int ret, sel = 8, fl = autolyr_blanklayers;
22535 bool running = true;
22536 do
22537 {
22538 SETFLAG(autolayer_dlg[3].flags, D_SELECTED, sel==3);
22539 SETFLAG(autolayer_dlg[8].flags, D_SELECTED, sel==8);
22540 SETFLAG(autolayer_dlg[9].flags, D_SELECTED, sel==9);
22541 switch(ret=do_zqdialog(autolayer_dlg,0))
22542 {
22543 case 4: //OK
22544 {
22545 int32_t lmap=vbound(atoi(mlayer),0,Map.getMapCount());
22546 al[layer][0]=lmap;
22547 tempscr->layermap[layer]=lmap;
22548 tempscr->layerscreen[layer]=Map.getCurrScr();
22549 al[layer][1]=fl;
22550 al[layer][2]=1;
22551 running = false;
22552 break;
22553 }
22554 case 0: case 5: //cancel
22555 running = false;
22556 break;
22557 case 3:
22558 sel = ret;
22559 fl = autolyr_blankscreens;
22560 break;
22561 case 8:
22562 sel = ret;
22563 fl = autolyr_blanklayers;
22564 break;
22565 case 9:
22566 sel = ret;
22567 fl = autolyr_any;
22568 break;
22569 }
22570 }
22571 while(ret != 0 && ret != 4 && ret != 5);
22572 }
22573
22574 int32_t onLayers()
22575 {
22576 mapscr tempscr=*Map.CurrScr();
22577 int32_t al[6][3]; //autolayer[layer][0=map, 1=autolyr_ type, 2=bool go]
22578
22579 for(int32_t i=0; i<6; i++)
22580 {
22581 al[i][0]=tempscr.layermap[i];
22582 al[i][1]=0;
22583 al[i][2]=0;
22584 }
22585
22586 int32_t ret;
22587
22588 do
22589 {
22590 ret=edit_layers(&tempscr);
22591
22592 if(ret>2) //autolayer button
22593 {
22594 autolayer(&tempscr, ret-30, al);
22595 }
22596 }
22597 while(ret>2); //autolayer button
22598
22599 if(ret==2) //OK
22600 {
22601 saved=false;
22602 TheMaps[Map.getCurrMap()*MAPSCRS+Map.getCurrScr()]=tempscr;
22603
22604 for(int32_t i=0; i<6; i++)
22605 {
22606 int32_t tm=tempscr.layermap[i]-1;
22607 int32_t ts=tempscr.layerscreen[i];
22608
22609 if(al[i][2])
22610 {
22611 map_autolayers[Map.getCurrMap()*6+i] = al[i][0];
22612 for(int32_t j=0; j<128; j++)
22613 {
22614 auto& curmapscr = TheMaps[Map.getCurrMap()*MAPSCRS+j];
22615 if(al[i][1] == autolyr_blankscreens && (curmapscr.valid&mVALID))
22616 continue;
22617 else if(al[i][1] == autolyr_blanklayers && curmapscr.layermap[i])
22618 continue;
22619
22620 curmapscr.layermap[i]=al[i][0];
22621 curmapscr.layerscreen[i]=al[i][0]?j:0;
22622 }
22623 }
22624 }
22625 }
22626
22627 // Check that the working layer wasn't just disabled
22628 if(CurrentLayer>0 && tempscr.layermap[CurrentLayer-1]==0)
22629 CurrentLayer=0;
22630
22631 return D_O_K;
22632 }
22633
22634
22635 char *itoa(int32_t i)
22636 {
22637 static char itoaret[500];
22638 sprintf(itoaret, "%d", i);
22639 return itoaret;
22640 }
22641
22642 21 void fps_callback()
22643 {
22644 21 lastfps=framecnt;
22645 21 framecnt=0;
22646 21 }
22647
22648 END_OF_FUNCTION(fps_callback)
22649
22650 //uint32_t col_diff[3*128];
22651 /*
22652 void bestfit_init(void)
22653 {
22654 int32_t i;
22655
22656 for (i=1; i<64; i++)
22657
22658 {
22659 int32_t k = i * i;
22660 col_diff[0 +i] = col_diff[0 +128-i] = k * (59 * 59);
22661 col_diff[128+i] = col_diff[128+128-i] = k * (30 * 30);
22662 col_diff[256+i] = col_diff[256+128-i] = k * (11 * 11);
22663 }
22664 }
22665 */
22666 21 void create_rgb_table2(RGB_MAP *table, AL_CONST PALETTE pal_8bit, void (*callback)(int32_t pos))
22667 {
22668 #define UNUSED 65535
22669 #define LAST 65532
22670
22671 // Allegro has been modified to use an 8 bit palette, but this method and RGB_MAP still use 6 bit.
22672 PALETTE pal;
22673
2/2
✓ Branch 0 taken 5376 times.
✓ Branch 1 taken 21 times.
5397 for (int i = 0; i < 256; i++)
22674 {
22675 5376 pal[i] = pal_8bit[i];
22676 5376 pal[i].r /= 4;
22677 5376 pal[i].g /= 4;
22678 5376 pal[i].b /= 4;
22679 5376 }
22680
22681 /* macro add adds to single linked list */
22682 #define add(i) (next[(i)] == UNUSED ? (next[(i)] = LAST, \
22683 (first != LAST ? (next[last] = (i)) : (first = (i))), \
22684 (last = (i))) : 0)
22685
22686 /* same but w/o checking for first element */
22687 #define add1(i) (next[(i)] == UNUSED ? (next[(i)] = LAST, \
22688 next[last] = (i), \
22689 (last = (i))) : 0)
22690 /* calculates distance between two colors */
22691 #define dist(a1, a2, a3, b1, b2, b3) \
22692 (col_diff[ ((a2) - (b2)) & 0x7F] + \
22693 (col_diff + 128)[((a1) - (b1)) & 0x7F] + \
22694 (col_diff + 256)[((a3) - (b3)) & 0x7F])
22695
22696 /* converts r,g,b to position in array and back */
22697 #define pos(r, g, b) \
22698 (((r) / 2) * 32 * 32 + ((g) / 2) * 32 + ((b) / 2))
22699
22700 #define depos(pal, r, g, b) \
22701 ((b) = ((pal) & 31) * 2, \
22702 (g) = (((pal) >> 5) & 31) * 2, \
22703 (r) = (((pal) >> 10) & 31) * 2)
22704
22705 /* is current color better than pal1? */
22706 #define better(r1, g1, b1, pal1) \
22707 (((int32_t)dist((r1), (g1), (b1), \
22708 (pal1).r, (pal1).g, (pal1).b)) > (int32_t)dist2)
22709
22710 /* checking of position */
22711 #define dopos(rp, gp, bp, ts) \
22712 if ((rp > -1 || r > 0) && (rp < 1 || r < 61) && \
22713 (gp > -1 || g > 0) && (gp < 1 || g < 61) && \
22714 (bp > -1 || b > 0) && (bp < 1 || b < 61)) \
22715 { \
22716 i = first + rp * 32 * 32 + gp * 32 + bp; \
22717 if (!data[i]) \
22718 { \
22719 data[i] = val; \
22720 add1(i); \
22721 } \
22722 else if ((ts) && (data[i] != val)) \
22723 { \
22724 dist2 = (rp ? (col_diff+128)[(r+2*rp-pal[val].r) & 0x7F] : r2) + \
22725 (gp ? (col_diff )[(g+2*gp-pal[val].g) & 0x7F] : g2) + \
22726 (bp ? (col_diff+256)[(b+2*bp-pal[val].b) & 0x7F] : b2); \
22727 if (better((r+2*rp), (g+2*gp), (b+2*bp), pal[data[i]])) \
22728 { \
22729 data[i] = val; \
22730 add1(i); \
22731 } \
22732 } \
22733 }
22734
22735 int32_t i, curr, r, g, b, val, dist2;
22736 uint32_t r2, g2, b2;
22737 uint16_t next[32*32*32];
22738 uint8_t *data;
22739 21 int32_t first = LAST;
22740 21 int32_t last = LAST;
22741 21 int32_t count = 0;
22742 21 int32_t cbcount = 0;
22743
22744 #define AVERAGE_COUNT 18000
22745
22746
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 10 times.
21 if(col_diff[1] == 0)
22747 11 bestfit_init();
22748
22749 21 memset(next, 255, sizeof(next));
22750 21 memset(table->data, 0, sizeof(char)*32*32*32);
22751
22752
22753 21 data = (uint8_t *)table->data;
22754
22755 /* add starting seeds for floodfill */
22756
2/2
✓ Branch 0 taken 5355 times.
✓ Branch 1 taken 21 times.
5376 for(i=1; i<PAL_SIZE; i++)
22757 {
22758 5355 curr = pos(pal[i].r, pal[i].g, pal[i].b);
22759
22760
2/2
✓ Branch 0 taken 4053 times.
✓ Branch 1 taken 1302 times.
5355 if(next[curr] == UNUSED)
22761 {
22762 1302 data[curr] = i;
22763
3/4
✓ Branch 0 taken 1302 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1281 times.
✓ Branch 3 taken 21 times.
1302 add(curr);
22764 1302 }
22765 5355 }
22766
22767 /* main floodfill: two versions of loop for faster growing in blue axis */
22768 // while (first != LAST) {
22769
2/2
✓ Branch 0 taken 450575 times.
✓ Branch 1 taken 21 times.
450596 while(first < LAST)
22770 {
22771 450575 depos(first, r, g, b);
22772
22773 /* calculate distance of current color */
22774 450575 val = data[first];
22775 450575 r2 = (col_diff+128)[((pal[val].r)-(r)) & 0x7F];
22776 450575 g2 = (col_diff)[((pal[val].g)-(g)) & 0x7F];
22777 450575 b2 = (col_diff+256)[((pal[val].b)-(b)) & 0x7F];
22778
22779 /* try to grow to all directions */
22780 #ifdef _MSC_VER
22781 #pragma warning(disable:4127)
22782 #endif
22783
11/12
✓ Branch 0 taken 14797 times.
✓ Branch 1 taken 435778 times.
✓ Branch 2 taken 418414 times.
✓ Branch 3 taken 17364 times.
✓ Branch 4 taken 17364 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 349903 times.
✓ Branch 7 taken 68511 times.
✓ Branch 8 taken 19107 times.
✓ Branch 9 taken 49404 times.
✓ Branch 10 taken 30562 times.
✓ Branch 11 taken 18842 times.
868989 dopos(0, 0, 1, 1);
22784
11/12
✓ Branch 0 taken 13307 times.
✓ Branch 1 taken 437268 times.
✓ Branch 2 taken 421926 times.
✓ Branch 3 taken 15342 times.
✓ Branch 4 taken 15342 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 367287 times.
✓ Branch 7 taken 54639 times.
✓ Branch 8 taken 21549 times.
✓ Branch 9 taken 33090 times.
✓ Branch 10 taken 21770 times.
✓ Branch 11 taken 11320 times.
872501 dopos(0, 0,-1, 1);
22785
11/12
✓ Branch 0 taken 14382 times.
✓ Branch 1 taken 436193 times.
✓ Branch 2 taken 424908 times.
✓ Branch 3 taken 11285 times.
✓ Branch 4 taken 11285 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 347042 times.
✓ Branch 7 taken 77866 times.
✓ Branch 8 taken 50354 times.
✓ Branch 9 taken 27512 times.
✓ Branch 10 taken 17286 times.
✓ Branch 11 taken 10226 times.
875483 dopos(1, 0, 0, 1);
22786
11/12
✓ Branch 0 taken 14499 times.
✓ Branch 1 taken 436076 times.
✓ Branch 2 taken 424084 times.
✓ Branch 3 taken 11992 times.
✓ Branch 4 taken 11992 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 349660 times.
✓ Branch 7 taken 74424 times.
✓ Branch 8 taken 49118 times.
✓ Branch 9 taken 25306 times.
✓ Branch 10 taken 16008 times.
✓ Branch 11 taken 9298 times.
874659 dopos(-1, 0, 0, 1);
22787
11/12
✓ Branch 0 taken 14539 times.
✓ Branch 1 taken 436036 times.
✓ Branch 2 taken 391471 times.
✓ Branch 3 taken 44565 times.
✓ Branch 4 taken 44565 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 290643 times.
✓ Branch 7 taken 100828 times.
✓ Branch 8 taken 83046 times.
✓ Branch 9 taken 17782 times.
✓ Branch 10 taken 11492 times.
✓ Branch 11 taken 6290 times.
842046 dopos(0, 1, 0, 1);
22788
11/12
✓ Branch 0 taken 13124 times.
✓ Branch 1 taken 437451 times.
✓ Branch 2 taken 399232 times.
✓ Branch 3 taken 38219 times.
✓ Branch 4 taken 38219 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 299384 times.
✓ Branch 7 taken 99848 times.
✓ Branch 8 taken 85123 times.
✓ Branch 9 taken 14725 times.
✓ Branch 10 taken 9189 times.
✓ Branch 11 taken 5536 times.
849807 dopos(0,-1, 0, 1);
22789 #ifdef _MSC_VER
22790 #pragma warning(default:4127)
22791 #endif
22792
22793 /* faster growing of blue direction */
22794
4/4
✓ Branch 0 taken 437268 times.
✓ Branch 1 taken 13307 times.
✓ Branch 2 taken 21549 times.
✓ Branch 3 taken 415719 times.
450575 if((b > 0) && (data[first-1] == val))
22795 {
22796 415719 b -= 2;
22797 415719 first--;
22798 415719 b2 = (col_diff+256)[((pal[val].b)-(b)) & 0x7F];
22799
22800 #ifdef _MSC_VER
22801 #pragma warning(disable:4127)
22802 #endif
22803
5/6
✓ Branch 0 taken 13508 times.
✓ Branch 1 taken 402211 times.
✓ Branch 2 taken 366059 times.
✓ Branch 3 taken 36152 times.
✓ Branch 4 taken 36152 times.
✗ Branch 5 not taken.
781778 dopos(-1, 0, 0, 0);
22804
5/6
✓ Branch 0 taken 13364 times.
✓ Branch 1 taken 402355 times.
✓ Branch 2 taken 365610 times.
✓ Branch 3 taken 36745 times.
✓ Branch 4 taken 36745 times.
✗ Branch 5 not taken.
781329 dopos(1, 0, 0, 0);
22805
5/6
✓ Branch 0 taken 12197 times.
✓ Branch 1 taken 403522 times.
✓ Branch 2 taken 355860 times.
✓ Branch 3 taken 47662 times.
✓ Branch 4 taken 47662 times.
✗ Branch 5 not taken.
771579 dopos(0,-1, 0, 0);
22806
5/6
✓ Branch 0 taken 13551 times.
✓ Branch 1 taken 402168 times.
✓ Branch 2 taken 336590 times.
✓ Branch 3 taken 65578 times.
✓ Branch 4 taken 65578 times.
✗ Branch 5 not taken.
752309 dopos(0, 1, 0, 0);
22807 #ifdef _MSC_VER
22808 #pragma warning(default:4127)
22809 #endif
22810
22811 415719 first++;
22812 415719 }
22813
22814 /* get next from list */
22815 450575 i = first;
22816 450575 first = next[first];
22817 450575 next[i] = UNUSED;
22818
22819 /* second version of loop */
22820 // if (first != LAST) {
22821
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 450564 times.
450575 if(first < LAST)
22822 {
22823
22824 450564 depos(first, r, g, b);
22825
22826 450564 val = data[first];
22827 450564 r2 = (col_diff+128)[((pal[val].r)-(r)) & 0x7F];
22828 450564 g2 = (col_diff)[((pal[val].g)-(g)) & 0x7F];
22829 450564 b2 = (col_diff+256)[((pal[val].b)-(b)) & 0x7F];
22830
22831 #ifdef _MSC_VER
22832 #pragma warning(disable:4127)
22833 #endif
22834
11/12
✓ Branch 0 taken 14370 times.
✓ Branch 1 taken 436194 times.
✓ Branch 2 taken 415857 times.
✓ Branch 3 taken 20337 times.
✓ Branch 4 taken 20337 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 347408 times.
✓ Branch 7 taken 68449 times.
✓ Branch 8 taken 19063 times.
✓ Branch 9 taken 49386 times.
✓ Branch 10 taken 30486 times.
✓ Branch 11 taken 18900 times.
866421 dopos(0, 0, 1, 1);
22835
11/12
✓ Branch 0 taken 13244 times.
✓ Branch 1 taken 437320 times.
✓ Branch 2 taken 424306 times.
✓ Branch 3 taken 13014 times.
✓ Branch 4 taken 13014 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 369421 times.
✓ Branch 7 taken 54885 times.
✓ Branch 8 taken 21923 times.
✓ Branch 9 taken 32962 times.
✓ Branch 10 taken 21778 times.
✓ Branch 11 taken 11184 times.
874870 dopos(0, 0,-1, 1);
22836
11/12
✓ Branch 0 taken 14583 times.
✓ Branch 1 taken 435981 times.
✓ Branch 2 taken 424300 times.
✓ Branch 3 taken 11681 times.
✓ Branch 4 taken 11681 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 346291 times.
✓ Branch 7 taken 78009 times.
✓ Branch 8 taken 50641 times.
✓ Branch 9 taken 27368 times.
✓ Branch 10 taken 17229 times.
✓ Branch 11 taken 10139 times.
874864 dopos(1, 0, 0, 1);
22837
11/12
✓ Branch 0 taken 14345 times.
✓ Branch 1 taken 436219 times.
✓ Branch 2 taken 424380 times.
✓ Branch 3 taken 11839 times.
✓ Branch 4 taken 11839 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 349785 times.
✓ Branch 7 taken 74595 times.
✓ Branch 8 taken 49492 times.
✓ Branch 9 taken 25103 times.
✓ Branch 10 taken 16289 times.
✓ Branch 11 taken 8814 times.
874944 dopos(-1, 0, 0, 1);
22838
11/12
✓ Branch 0 taken 14476 times.
✓ Branch 1 taken 436088 times.
✓ Branch 2 taken 392433 times.
✓ Branch 3 taken 43655 times.
✓ Branch 4 taken 43655 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 292163 times.
✓ Branch 7 taken 100270 times.
✓ Branch 8 taken 82655 times.
✓ Branch 9 taken 17615 times.
✓ Branch 10 taken 11555 times.
✓ Branch 11 taken 6060 times.
842997 dopos(0, 1, 0, 1);
22839
11/12
✓ Branch 0 taken 13010 times.
✓ Branch 1 taken 437554 times.
✓ Branch 2 taken 399976 times.
✓ Branch 3 taken 37578 times.
✓ Branch 4 taken 37578 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 299995 times.
✓ Branch 7 taken 99981 times.
✓ Branch 8 taken 85368 times.
✓ Branch 9 taken 14613 times.
✓ Branch 10 taken 9367 times.
✓ Branch 11 taken 5246 times.
850540 dopos(0,-1, 0, 1);
22840 #ifdef _MSC_VER
22841 #pragma warning(default:4127)
22842 #endif
22843
22844
4/4
✓ Branch 0 taken 436194 times.
✓ Branch 1 taken 14370 times.
✓ Branch 2 taken 19063 times.
✓ Branch 3 taken 417131 times.
450564 if((b < 61) && (data[first + 1] == val))
22845 {
22846 417131 b += 2;
22847 417131 first++;
22848 417131 b2 = (col_diff+256)[((pal[val].b)-(b)) & 0x7f];
22849 #ifdef _MSC_VER
22850 #pragma warning(disable:4127)
22851 #endif
22852
5/6
✓ Branch 0 taken 13397 times.
✓ Branch 1 taken 403734 times.
✓ Branch 2 taken 361902 times.
✓ Branch 3 taken 41832 times.
✓ Branch 4 taken 41832 times.
✗ Branch 5 not taken.
779033 dopos(-1, 0, 0, 0);
22853
5/6
✓ Branch 0 taken 13497 times.
✓ Branch 1 taken 403634 times.
✓ Branch 2 taken 354721 times.
✓ Branch 3 taken 48913 times.
✓ Branch 4 taken 48913 times.
✗ Branch 5 not taken.
771852 dopos(1, 0, 0, 0);
22854
5/6
✓ Branch 0 taken 12034 times.
✓ Branch 1 taken 405097 times.
✓ Branch 2 taken 338219 times.
✓ Branch 3 taken 66878 times.
✓ Branch 4 taken 66878 times.
✗ Branch 5 not taken.
755350 dopos(0,-1, 0, 0);
22855
5/6
✓ Branch 0 taken 13617 times.
✓ Branch 1 taken 403514 times.
✓ Branch 2 taken 337319 times.
✓ Branch 3 taken 66195 times.
✓ Branch 4 taken 66195 times.
✗ Branch 5 not taken.
754450 dopos(0, 1, 0, 0);
22856 #ifdef _MSC_VER
22857 #pragma warning(default:4127)
22858 #endif
22859
22860 417131 first--;
22861 417131 }
22862
22863 450564 i = first;
22864 450564 first = next[first];
22865 450564 next[i] = UNUSED;
22866 450564 }
22867
22868 450575 count++;
22869
22870
2/2
✓ Branch 0 taken 445178 times.
✓ Branch 1 taken 5397 times.
450575 if(count == (cbcount+1)*AVERAGE_COUNT/256)
22871 {
22872
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 5376 times.
5397 if(cbcount < 256)
22873 {
22874
1/2
✓ Branch 0 taken 5376 times.
✗ Branch 1 not taken.
5376 if(callback)
22875 callback(cbcount);
22876
22877 5376 cbcount++;
22878 5376 }
22879 5397 }
22880
22881 }
22882
22883 /* only the transparent (pink) color can be mapped to index 0 */
22884
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
21 if((pal[0].r == 63) && (pal[0].g == 0) && (pal[0].b == 63))
22885 table->data[31][0][31] = 0;
22886
22887
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 if(callback)
22888 while(cbcount < 256)
22889 callback(cbcount++);
22890 21 }
22891
22892 21 void rebuild_trans_table()
22893 {
22894 21 create_rgb_table2(&zq_rgb_table, RAMpal, NULL);
22895 21 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
22896 21 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
22897
22898
2/2
✓ Branch 0 taken 5376 times.
✓ Branch 1 taken 21 times.
5397 for(int32_t q=0; q<PAL_SIZE; q++)
22899 {
22900 5376 trans_table2.data[0][q] = q;
22901 5376 trans_table2.data[q][q] = q;
22902 5376 }
22903 21 }
22904
22905 int32_t isFullScreen()
22906 {
22907 return !is_windowed_mode();
22908 }
22909
22910 void hit_close_button()
22911 {
22912 close_button_quit=true;
22913 return;
22914 }
22915
22916 extern bool dirty_screen;
22917
22918 void anim_hw_screen(bool force)
22919 {
22920 // if (force || myvsync)
22921 {
22922 ++cpoolbrush_index;
22923
22924 if(prv_mode)
22925 {
22926 if(Map.get_prvtime())
22927 {
22928 Map.set_prvtime(Map.get_prvtime()-1);
22929
22930 if(!Map.get_prvtime())
22931 {
22932 prv_warp=1;
22933 }
22934 }
22935 }
22936 if(AnimationOn)
22937 {
22938 animate_combos();
22939 update_freeform_combos();
22940 }
22941
22942 if(CycleOn)
22943 cycle_palette();
22944
22945 animate_coords();
22946 update_hw_screen();
22947 }
22948 }
22949
22950 void custom_vsync()
22951 {
22952 anim_hw_screen(true);
22953 }
22954
22955 void switch_out()
22956 {
22957 zcmusic_pause(zcmusic, ZCM_PAUSE);
22958 zc_midi_pause();
22959 }
22960
22961 void switch_in()
22962 {
22963 if(exiting_program)
22964 return;
22965 zcmusic_pause(zcmusic, ZCM_RESUME);
22966 zc_midi_resume();
22967 }
22968
22969 void Z_eventlog(const char *format,...)
22970 {
22971 format=format; //to prevent a compiler warning
22972 }
22973
22974 int32_t get_currdmap()
22975 {
22976 return zinit.start_dmap;
22977 }
22978
22979 int32_t get_dlevel()
22980 {
22981 return DMaps[zinit.start_dmap].level;
22982 }
22983
22984 int32_t get_currscr()
22985 {
22986 return Map.getCurrScr();
22987 }
22988
22989 int32_t get_currmap()
22990 {
22991 return Map.getCurrMap();
22992 }
22993
22994 int32_t get_homescr()
22995 {
22996 return DMaps[zinit.start_dmap].cont;
22997 }
22998
22999 int get_screen_for_world_xy(int x, int y)
23000 {
23001 return -1;
23002 }
23003
23004 int current_item(int item_type, bool checkmagic, bool jinx_check, bool check_bunny)
23005 {
23006 //TODO remove as special case?? -DD
23007 if(item_type==itype_shield)
23008 {
23009 return 2;
23010 }
23011
23012 int id = current_item_id(item_type, checkmagic, jinx_check, check_bunny);
23013 return id > -1 ? itemsbuf[id].fam_type : 0;
23014 }
23015
23016 int current_item_power(int itemtype, bool checkmagic, bool jinx_check, bool check_bunny)
23017 {
23018 if (game)
23019 {
23020 int result = current_item_id(itemtype, checkmagic, jinx_check, check_bunny);
23021 return (result<0) ? 0 : itemsbuf[result].power;
23022 }
23023 return 1;
23024 }
23025
23026 int32_t current_item_id(int32_t itemtype, bool, bool, bool)
23027 {
23028 if (game)
23029 {
23030 int32_t result = -1;
23031 int32_t highestlevel = -1;
23032
23033 for (int32_t i = 0; i < MAXITEMS; i++)
23034 {
23035 if ((zq_ignore_item_ownership || game->get_item(i)) && itemsbuf[i].family == itemtype)
23036 {
23037 if (itemsbuf[i].fam_type >= highestlevel)
23038 {
23039 highestlevel = itemsbuf[i].fam_type;
23040 result = i;
23041 }
23042 }
23043 }
23044 return result;
23045 }
23046 for(int32_t i=0; i<MAXITEMS; i++)
23047 {
23048 if(itemsbuf[i].family==itemtype)
23049 return i;
23050 }
23051
23052 return -1;
23053 }
23054
23055
23056 bool can_use_item(int32_t item_type, int32_t item)
23057 {
23058 //these are here to bypass compiler warnings about unused arguments
23059 item_type=item_type;
23060 item=item;
23061
23062 return true;
23063 }
23064
23065 bool has_item(int32_t item_type, int32_t it)
23066 {
23067 //these are here to bypass compiler warnings about unused arguments
23068 item_type=item_type;
23069 it=it;
23070
23071 return true;
23072 }
23073
23074 int32_t get_bmaps(int32_t si)
23075 {
23076 //these are here to bypass compiler warnings about unused arguments
23077 si=si;
23078
23079 return 255;
23080 }
23081
23082 bool no_subscreen()
23083 {
23084 return false;
23085 }
23086
23087 12 static void allocate_crap()
23088 {
23089 12 filepath=(char*)malloc(2048);
23090 12 datapath=(char*)malloc(2048);
23091 12 midipath=(char*)malloc(2048);
23092 12 imagepath=(char*)malloc(2048);
23093 12 tmusicpath=(char*)malloc(2048);
23094 12 last_timed_save=(char*)malloc(2048);
23095
23096
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!filepath || !datapath || !imagepath || !midipath || !tmusicpath || !last_timed_save)
23097 {
23098 Z_error_fatal("Error: no memory for file paths!");
23099 }
23100
23101
23102 12 customtunes = (zctune*)malloc(sizeof(zctune)*MAXCUSTOMMIDIS_ZQ);
23103 12 memset(customtunes, 0, sizeof(zctune)*MAXCUSTOMMIDIS_ZQ);
23104
23105
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 12 times.
3084 for(int32_t i=0; i<MAXCUSTOMMIDIS_ZQ; ++i)
23106 {
23107 3072 customtunes[i].data=NULL;
23108 3072 }
23109
23110
2/2
✓ Branch 0 taken 3024 times.
✓ Branch 1 taken 12 times.
3036 for(int32_t i=0; i<MAXCUSTOMTUNES; i++)
23111 {
23112 3024 midi_string[i+4]=customtunes[i].title;
23113 3024 screen_midi_string[i+5]=customtunes[i].title;
23114 3024 }
23115
23116
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 12 times.
3084 for(int32_t i=0; i<WAV_COUNT; i++)
23117 {
23118
1/4
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3072 if(sfx_string[i]!=NULL) delete sfx_string[i];
23119 3072 customsfxdata[i].data=NULL;
23120 3072 sfx_string[i] = new char[36];
23121 3072 memset(sfx_string[i], 0, 36);
23122 3072 }
23123
23124
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 12 times.
3084 for(int32_t i=0; i<MAXWPNS; i++)
23125 {
23126
1/4
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3072 if(weapon_string[i]!=NULL) delete weapon_string[i];
23127 3072 weapon_string[i] = new char[64];
23128 3072 memset(weapon_string[i], 0, 64);
23129 3072 }
23130
23131
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 12 times.
3084 for(int32_t i=0; i<MAXITEMS; i++)
23132 {
23133
1/4
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3072 if(item_string[i]!=NULL) delete item_string[i];
23134 3072 item_string[i] = new char[64];
23135 3072 memset(item_string[i], 0, 64);
23136 3072 }
23137
23138
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 12 times.
6156 for(int32_t i=0; i<eMAXGUYS; i++)
23139 {
23140
1/4
✓ Branch 0 taken 6144 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6144 if(guy_string[i]!=NULL) delete guy_string[i];
23141 6144 guy_string[i] = new char[64];
23142 6144 memset(guy_string[i], 0, 64);
23143 6144 }
23144
23145
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 12 times.
6156 for(int32_t i=0; i<NUMSCRIPTFFC; i++)
23146 {
23147
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6144 times.
6144 delete ffscripts[i];
23148
1/2
✓ Branch 0 taken 6144 times.
✗ Branch 1 not taken.
6144 ffscripts[i] = new script_data(ScriptType::FFC, i);
23149 6144 }
23150
23151
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 12 times.
3084 for(int32_t i=0; i<NUMSCRIPTITEM; i++)
23152 {
23153
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 delete itemscripts[i];
23154
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 itemscripts[i] = new script_data(ScriptType::Item, i);
23155 3072 }
23156
23157
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 12 times.
3084 for(int32_t i=0; i<NUMSCRIPTGUYS; i++)
23158 {
23159
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 delete guyscripts[i];
23160
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 guyscripts[i] = new script_data(ScriptType::NPC, i);
23161 3072 }
23162
23163
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 12 times.
3084 for(int32_t i=0; i<NUMSCRIPTSCREEN; i++)
23164 {
23165
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 delete screenscripts[i];
23166
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 screenscripts[i] = new script_data(ScriptType::Screen, i);
23167 3072 }
23168
23169
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 12 times.
108 for(int32_t i=0; i<NUMSCRIPTGLOBAL; i++)
23170 {
23171
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 delete globalscripts[i];
23172
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 globalscripts[i] = new script_data(ScriptType::Global, i);
23173 96 }
23174
23175
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 12 times.
72 for(int32_t i=0; i<NUMSCRIPTHERO; i++)
23176 {
23177
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 delete playerscripts[i];
23178
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 playerscripts[i] = new script_data(ScriptType::Hero, i);
23179 60 }
23180
23181
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 12 times.
3084 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
23182 {
23183
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 delete lwpnscripts[i];
23184
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 lwpnscripts[i] = new script_data(ScriptType::Lwpn, i);
23185 3072 }
23186
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 12 times.
3084 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
23187 {
23188
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3072 times.
3072 delete ewpnscripts[i];
23189
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 ewpnscripts[i] = new script_data(ScriptType::Ewpn, i);
23190 3072 }
23191
23192
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 12 times.
3084 for(int32_t i=0; i<NUMSCRIPTSDMAP; i++)
23193 {
23194
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 delete dmapscripts[i];
23195
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 dmapscripts[i] = new script_data(ScriptType::DMap, i);
23196 3072 }
23197
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 12 times.
3084 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE; i++)
23198 {
23199
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 delete itemspritescripts[i];
23200
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 itemspritescripts[i] = new script_data(ScriptType::ItemSprite, i);
23201 3072 }
23202
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 12 times.
6156 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA; i++)
23203 {
23204
1/2
✓ Branch 0 taken 6144 times.
✗ Branch 1 not taken.
6144 delete comboscripts[i];
23205
1/2
✓ Branch 0 taken 6144 times.
✗ Branch 1 not taken.
6144 comboscripts[i] = new script_data(ScriptType::Combo, i);
23206 6144 }
23207
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 12 times.
6156 for(int32_t i=0; i<NUMSCRIPTSGENERIC; i++)
23208 {
23209
1/2
✓ Branch 0 taken 6144 times.
✗ Branch 1 not taken.
6144 delete genericscripts[i];
23210
1/2
✓ Branch 0 taken 6144 times.
✗ Branch 1 not taken.
6144 genericscripts[i] = new script_data(ScriptType::Generic, i);
23211 6144 }
23212
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 12 times.
3084 for(int32_t i=0; i<NUMSCRIPTSSUBSCREEN; i++)
23213 {
23214
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3072 times.
3072 delete subscreenscripts[i];
23215
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 subscreenscripts[i] = new script_data(ScriptType::EngineSubscreen, i);
23216 3072 }
23217 12 }
23218
23219 static void handle_sentry_tags()
23220 {
23221 static bool sentry_first_time = true;
23222
23223 static MapCursor sentry_last_map_cursor;
23224 if (Map.getCursor() != sentry_last_map_cursor || sentry_first_time)
23225 {
23226 sentry_last_map_cursor = Map.getCursor();
23227 zapp_reporting_set_tag("cursor.map", sentry_last_map_cursor.map);
23228 zapp_reporting_set_tag("cursor.screen", sentry_last_map_cursor.screen);
23229 zapp_reporting_set_tag("cursor.viewscr", sentry_last_map_cursor.viewscr);
23230 zapp_reporting_set_tag("cursor.size", sentry_last_map_cursor.size);
23231 }
23232
23233 static bool sentry_last_is_compact;
23234 if (is_compact != sentry_last_is_compact || sentry_first_time)
23235 {
23236 sentry_last_is_compact = is_compact;
23237 zapp_reporting_set_tag("compact", sentry_last_is_compact);
23238 }
23239
23240 sentry_first_time = false;
23241 }
23242
23243 // Removes the top layer encoding from a quest file. See open_quest_file.
23244 // This has zero impact on the contents of the quest file. There should be no way for this to
23245 // break anything.
23246 static void do_unencrypt_qst_command(const char* input_filename, const char* output_filename)
23247 {
23248 // If the file is already an unencrypted packfile, there's nothing to do.
23249 PACKFILE* pf_check = pack_fopen_password(input_filename, F_READ_PACKED, "");
23250 pack_fclose(pf_check);
23251 if (pf_check) return;
23252
23253 int32_t error;
23254 PACKFILE* pf = open_quest_file(&error, input_filename, false);
23255 PACKFILE* pf2 = pack_fopen_password(output_filename, F_WRITE_PACKED, "");
23256 int c;
23257 while ((c = pack_getc(pf)) != EOF)
23258 {
23259 pack_putc(c, pf2);
23260 }
23261 pack_fclose(pf);
23262 pack_fclose(pf2);
23263 clear_quest_tmpfile();
23264 }
23265
23266 // This will remove the PACKFILE compression. Incidentally, it also removes the top encoding layer.
23267 static void do_uncompress_qst_command(const char* input_filename, const char* output_filename)
23268 {
23269 auto unencrypted_result = try_open_maybe_legacy_encoded_file(input_filename, ENC_STR, nullptr, QH_NEWIDSTR, QH_IDSTR);
23270 if (unencrypted_result.not_found)
23271 {
23272 printf("qst not found\n");
23273 zq_exit(1);
23274 }
23275 if (!unencrypted_result.compressed && !unencrypted_result.encrypted)
23276 {
23277 // If the file is already an uncompressed file, there's nothing to do but copy it.
23278 fs::copy(input_filename, output_filename);
23279 return;
23280 }
23281
23282 pack_fclose(unencrypted_result.decoded_pf);
23283
23284 int32_t error;
23285 PACKFILE* pf = open_quest_file(&error, input_filename, false);
23286 PACKFILE* pf2 = pack_fopen_password(output_filename, F_WRITE, "");
23287 int c;
23288 while ((c = pack_getc(pf)) != EOF)
23289 {
23290 pack_putc(c, pf2);
23291 }
23292 pack_fclose(pf);
23293 pack_fclose(pf2);
23294 clear_quest_tmpfile();
23295 }
23296
23297 // Copy a quest file by loading and resaving, exactly like if the user did it in the UI.
23298 // Note there could be changes introduced in the loading or saving functions. These are
23299 // typically for compatability, but could possibly be a source of bugs.
23300 3 static void do_copy_qst_command(const char* input_filename, const char* output_filename)
23301 {
23302 3 set_headless_mode();
23303
23304 // We need to init some stuff before loading a quest file will work.
23305 3 int fake_errno = 0;
23306 3 allegro_errno = &fake_errno;
23307 3 get_qst_buffers();
23308
23309 3 int ret = load_quest(input_filename, false);
23310
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (ret)
23311 {
23312 zq_exit(ret);
23313 }
23314
23315 3 ret = save_quest(output_filename, false);
23316 3 zq_exit(ret);
23317 3 }
23318
23319 int32_t Awpn=-1, Bwpn=-1, Xwpn = -1, Ywpn = -1;
23320 84 sprite_list guys, items, Ewpns, Lwpns, chainlinks, decorations, portals;
23321 int32_t exittimer = 10000, exittimer2 = 100;
23322
23323 1 static bool partial_load_test(const char* test_dir)
23324 {
23325
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 auto classic_path = fs::path(test_dir) / "replays/classic_1st.qst";
23326
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 int ret = load_quest(classic_path.string().c_str(), false);
23327
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (ret)
23328 {
23329 printf("failed to load classic_1st.qst: ret == %d\n", ret);
23330 return false;
23331 }
23332
23333 1 int cont = DMaps[0].cont;
23334
23335 // Skip same stuff as used in zq_tiles.cpp for grabbing tiles from a qst.
23336 byte skip_flags[4];
23337
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 26 times.
27 for (int i=0; i<skip_max; ++i)
23338
1/2
✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
26 set_bit(skip_flags,i,1);
23339
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 set_bit(skip_flags,skip_tiles,0);
23340
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 set_bit(skip_flags,skip_header,0);
23341 1 zquestheader tempheader{};
23342
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 auto ptux_path = fs::path(test_dir) / "quests/PTUX.qst";
23343
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 ret = loadquest(ptux_path.string().c_str(), &tempheader, &QMisc, customtunes, false, skip_flags);
23344
23345
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (ret)
23346 {
23347 printf("failed to load PTUX.qst: ret == %d\n", ret);
23348 return false;
23349 }
23350
23351
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (DMaps[0].cont != cont)
23352 {
23353 printf("unexpected modification: DMaps[0].cont == %d, should be %d\n", DMaps[0].cont, cont);
23354 return false;
23355 }
23356
23357 // TODO should run replay. Currently, resaving classic_1st.qst fails its replay (see test_save in test_zeditor.py)
23358
23359 1 return true;
23360 1 }
23361
23362 template <typename ...Params>
23363 [[noreturn]] void FatalConsole(const char *format, Params&&... params)
23364 {
23365 FFCore.ZScriptConsole(CConsoleLoggerEx::COLOR_RED|CConsoleLoggerEx::COLOR_INTENSITY|CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"");
23366 Z_error_fatal(format, std::forward<Params>(params)...);
23367 }
23368
23369 40 static BITMAP* load_asset_bmp(const char* path)
23370 {
23371 40 BITMAP* bmp = load_bmp(path, nullptr);
23372
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if (!bmp)
23373 Z_error_fatal("Failed to load required asset: %s\n", path);
23374 40 return bmp;
23375 }
23376
23377 8 static void load_asset_pal(PALETTE pal, const char* path)
23378 {
23379 8 BITMAP* bmp = load_bmp(path, pal);
23380
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if (!bmp)
23381 Z_error_fatal("Failed to load required asset: %s\n", path);
23382 8 }
23383
23384 8 static MIDI* load_asset_midi(const char* path)
23385 {
23386 8 MIDI* midi = load_midi(path);
23387
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if (!midi)
23388 Z_error_fatal("Failed to load required asset: %s\n", path);
23389 8 return midi;
23390 }
23391
23392 BITMAP* asset_icons_bmp;
23393 BITMAP* asset_engravings_bmp;
23394 BITMAP* asset_mouse_bmp;
23395 BITMAP* asset_select_bmp;
23396 BITMAP* asset_arrows_bmp;
23397 MIDI* asset_tunes_midi;
23398 PALETTE asset_pal;
23399
23400 8 static void load_assets()
23401 {
23402 8 asset_icons_bmp = load_asset_bmp("assets/editor/icons.bmp");
23403 8 asset_engravings_bmp = load_asset_bmp("assets/editor/engravings.bmp");
23404 8 asset_mouse_bmp = load_asset_bmp("assets/editor/mouse.bmp");
23405 8 asset_select_bmp = load_asset_bmp("assets/editor/select.bmp");
23406 8 asset_arrows_bmp = load_asset_bmp("assets/editor/arrows.bmp");
23407 8 asset_tunes_midi = load_asset_midi("assets/editor/tunes.mid");
23408 8 load_asset_pal(asset_pal, "assets/editor/pal.bmp");
23409 8 }
23410
23411 static bool application_has_loaded;
23412
23413 8 int32_t main(int32_t argc,char **argv)
23414 {
23415 8 int test_zc_arg = used_switch(argc, argv, "-test-zc");
23416
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 1 times.
8 if (test_zc_arg > 0)
23417 1 set_headless_mode();
23418
23419 8 zalleg_setup_allegro(App::zquest, argc, argv);
23420 8 allocate_crap();
23421
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 set_should_zprint_cb([]() {
23422 return get_qr(qr_SCRIPTERRLOG) || DEVLEVEL > 0;
23423 });
23424
23425 8 int package_arg = used_switch(argc, argv, "-package");
23426
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if (package_arg > 0)
23427 {
23428 if (package_arg + 3 > argc)
23429 {
23430 printf("%d\n", argc);
23431 printf("expected -package <game.qst> <package name>\n");
23432 zq_exit(1);
23433 }
23434
23435 const char* input_filename = argv[package_arg + 1];
23436 const char* package_name = argv[package_arg + 2];
23437 if (auto error = package_create(input_filename, package_name))
23438 Z_error_fatal("%s\n", error->c_str());
23439 zq_exit(0);
23440 }
23441
23442 8 int copy_qst_arg = used_switch(argc, argv, "-copy-qst");
23443
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 5 times.
8 if (copy_qst_arg > 0)
23444 {
23445
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (copy_qst_arg + 3 > argc)
23446 {
23447 printf("%d\n", argc);
23448 printf("expected -copy-qst <input> <output>\n");
23449 zq_exit(1);
23450 }
23451
23452 3 const char* input_filename = argv[copy_qst_arg + 1];
23453 3 const char* output_filename = argv[copy_qst_arg + 2];
23454 3 do_copy_qst_command(input_filename, output_filename);
23455 3 }
23456
23457 8 Z_title("ZQuest Classic Editor, %s", getVersionString());
23458
23459
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!get_qst_buffers())
23460 {
23461 Z_error_fatal("Error");
23462 }
23463
23464 8 undocombobuf.clear();
23465 8 undocombobuf.resize(MAXCOMBOS);
23466
23467
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if((newundotilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
23468 {
23469 Z_error_fatal("Error: no memory for tile undo buffer!");
23470 }
23471
23472 8 memset(newundotilebuf, 0, NEWMAXTILES*sizeof(tiledata));
23473
23474 8 Z_message("Resetting new tile buffer...");
23475 8 newtilebuf = (tiledata*)malloc(NEWMAXTILES*sizeof(tiledata));
23476
23477
2/2
✓ Branch 0 taken 1930500 times.
✓ Branch 1 taken 8 times.
1930508 for(int32_t j=0; j<NEWMAXTILES; j++)
23478 1930500 newtilebuf[j].data=NULL;
23479
23480 8 Z_message("OK\n");
23481
23482 8 zc_srand(time(0));
23483
23484
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 7 times.
8 if (test_zc_arg > 0)
23485 {
23486 1 set_headless_mode();
23487
23488
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (test_zc_arg + 1 > argc)
23489 {
23490 printf("%d\n", argc);
23491 printf("expected -test-zc <path to test dir>\n");
23492 zq_exit(1);
23493 }
23494
23495 1 const char* test_dir = argv[test_zc_arg + 1];
23496
23497 // We need to init some stuff before loading a quest file will work.
23498 1 int fake_errno = 0;
23499 1 allegro_errno = &fake_errno;
23500 1 get_qst_buffers();
23501
23502 1 bool success = true;
23503
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (!partial_load_test(test_dir))
23504 {
23505 success = false;
23506 printf("partial_load_test failed\n");
23507 }
23508
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (success)
23509 1 printf("all tests passed\n");
23510 1 zq_exit(success ? 0 : 1);
23511 1 }
23512
23513 8 int unencrypt_qst_arg = used_switch(argc, argv, "-unencrypt-qst");
23514
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if (unencrypt_qst_arg > 0)
23515 {
23516 if (unencrypt_qst_arg + 3 > argc)
23517 {
23518 printf("%d\n", argc);
23519 printf("expected -unencrypt-qst <input> <output>\n");
23520 zq_exit(1);
23521 }
23522
23523 const char* input_filename = argv[unencrypt_qst_arg + 1];
23524 const char* output_filename = argv[unencrypt_qst_arg + 2];
23525 do_unencrypt_qst_command(input_filename, output_filename);
23526 zq_exit(0);
23527 }
23528
23529 8 int uncompress_qst_arg = used_switch(argc, argv, "-uncompress-qst");
23530
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if (uncompress_qst_arg > 0)
23531 {
23532 if (uncompress_qst_arg + 3 > argc)
23533 {
23534 printf("%d\n", argc);
23535 printf("expected -uncompress-qst <input> <output>\n");
23536 zq_exit(1);
23537 }
23538
23539 const char* input_filename = argv[uncompress_qst_arg + 1];
23540 const char* output_filename = argv[uncompress_qst_arg + 2];
23541 do_uncompress_qst_command(input_filename, output_filename);
23542 zq_exit(0);
23543 }
23544
23545 8 three_finger_flag=false;
23546
23547 #ifndef __EMSCRIPTEN__
23548
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(zc_get_config("zquest","open_debug_console",0))
23549 initConsole();
23550 #endif
23551
23552 LOCK_VARIABLE(lastfps);
23553
23554 LOCK_VARIABLE(framecnt);
23555 LOCK_FUNCTION(fps_callback);
23556
23557
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(install_int_ex(fps_callback,SECS_TO_TIMER(1)))
23558 {
23559 Z_error_fatal("couldn't allocate timer");
23560 }
23561
23562
23563 LOCK_VARIABLE(dclick_status);
23564 LOCK_VARIABLE(dclick_time);
23565 8 lock_dclick_function();
23566 8 install_int(dclick_check, 20);
23567
23568 8 set_gfx_mode(GFX_TEXT,80,50,0,0);
23569
23570 8 load_assets();
23571
23572 8 Z_message("OK\n");
23573
23574
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 helpstr = util::read_text_file("docs/zquest.txt");
23575
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 zstringshelpstr = util::read_text_file("docs/zstrings.txt");
23576
23577 // loading data files...
23578
23579 8 filepath[0]=temppath[0]=0;
23580
23581 8 const char *default_path="";
23582
23583 8 strcpy(datapath,zc_get_config("zquest",data_path_name,default_path));
23584 8 strcpy(midipath,zc_get_config("zquest",midi_path_name,default_path));
23585 8 strcpy(imagepath,zc_get_config("zquest",image_path_name,default_path));
23586 8 strcpy(tmusicpath,zc_get_config("zquest",tmusic_path_name,default_path));
23587 8 chop_path(datapath);
23588 8 chop_path(midipath);
23589 8 chop_path(imagepath);
23590 8 chop_path(tmusicpath);
23591
23592 8 DisableLPalShortcuts = zc_get_config("zquest","dis_lpal_shortcut",1);
23593 8 DisableCompileConsole = zc_get_config("zquest","internal_compile_console",0);
23594 8 MouseScroll = zc_get_config("zquest","mouse_scroll",0);
23595 8 MMapCursorStyle = zc_get_config("zquest","cursorblink_style",1);
23596 8 LayerDitherBG = zc_get_config("zquest", "layer_dither_bg", -1);
23597 8 LayerDitherSz = zc_get_config("zquest", "layer_dither_sz", 3);
23598 8 InvalidBG = zc_get_config("zquest", "invalid_bg", 0);
23599 8 TileProtection = zc_get_config("zquest","tile_protection",1);
23600 8 ComboProtection = zc_get_config("zquest","combo_protection",TileProtection);
23601 8 ShowGrid = zc_get_config("zquest","show_grid",0);
23602 8 ShowCurScreenOutline = zc_get_config("zquest","show_current_screen_outline",1);
23603 8 ShowScreenGrid = zc_get_config("zquest","show_screen_grid",0);
23604 8 ShowRegionGrid = zc_get_config("zquest","show_region_grid",1);
23605 8 GridColor = zc_get_config("zquest","grid_color",15);
23606 8 CmbCursorCol = zc_get_config("zquest","combo_cursor_color",15);
23607 8 TilePgCursorCol = zc_get_config("zquest","tpage_cursor_color",15);
23608 8 CmbPgCursorCol = zc_get_config("zquest","cpage_cursor_color",15);
23609 8 TTipHLCol = zc_get_config("zquest","ttip_hl_color",13);
23610 8 CheckerCol1 = zc_get_config("zquest","checker_color_1",7);
23611 8 CheckerCol2 = zc_get_config("zquest","checker_color_2",8);
23612 8 SnapshotFormat = zc_get_config("zquest","snapshot_format",3);
23613 8 SnapshotScale = zc_get_config("zquest","snapshot_scale",2);
23614 8 SavePaths = zc_get_config("zquest","save_paths",1);
23615 8 CycleOn = zc_get_config("zquest","cycle_on",1);
23616 8 ShowFPS = zc_get_config("zquest","showfps",0)!=0;
23617 8 SaveDragResize = zc_get_config("zquest","save_drag_resize",0)!=0;
23618 8 DragAspect = zc_get_config("zquest","drag_aspect",0)!=0;
23619 8 SaveWinPos = zc_get_config("zquest","save_window_position",0)!=0;
23620 8 ComboBrush = zc_get_config("zquest","combo_brush",0);
23621 8 FloatBrush = zc_get_config("zquest","float_brush",0);
23622 8 AutoBrush = zc_get_config("zquest","autobrush",1);
23623 8 LinkedScroll = zc_get_config("zquest","linked_comboscroll",0);
23624 8 allowHideMouse = zc_get_config("ZQ_GUI","allowHideMouse",0);
23625 8 ShowFavoriteComboModes = zc_get_config("ZQ_GUI","show_fav_combo_modes",1);
23626 8 NoHighlightLayer0 = zc_get_config("zquest","no_highlight_layer0",0);
23627 8 RulesetDialog = zc_get_config("zquest","rulesetdialog",1);
23628 8 EnableTooltips = zc_get_config("zquest","enable_tooltips",1);
23629 8 TooltipsHighlight = zc_get_config("zquest","ttip_highlight",1);
23630 8 tooltip_maxtimer = vbound(zc_get_config("zquest","ttip_timer",30),0,60*60);
23631 8 ShowFFScripts = zc_get_config("zquest","showffscripts",1);
23632 8 ShowSquares = zc_get_config("zquest","showsquares",1);
23633 8 ShowFFCs = zc_get_config("zquest","showffcs",0);
23634 8 ShowInfo = zc_get_config("zquest","showinfo",1);
23635 8 skipLayerWarning = zc_get_config("zquest","skip_layer_warning",0);
23636 8 numericalFlags = zc_get_config("zquest","numerical_flags",0);
23637 8 ViewLayer2BG = zc_get_config("zquest","layer2_bg",0);
23638 8 ViewLayer3BG = zc_get_config("zquest","layer3_bg",0);
23639 8 ActiveLayerHighlight = zc_get_config("zquest","hl_active_lyr",0);
23640 8 DragCenterOfSquares = zc_get_config("zquest","drag_squares_from_center",0);
23641
23642 8 OpenLastQuest = zc_get_config("zquest","open_last_quest",0);
23643 8 ShowMisalignments = zc_get_config("zquest","show_misalignments",0);
23644 8 AnimationOn = zc_get_config("zquest","animation_on",1);
23645 8 AutoBackupRetention = zc_get_config("zquest","auto_backup_retention",2);
23646 8 AutoSaveInterval = zc_get_config("zquest","auto_save_interval",6);
23647 8 AutoSaveRetention = zc_get_config("zquest","auto_save_retention",2);
23648 8 UncompressedAutoSaves = zc_get_config("zquest","uncompressed_auto_saves",1);
23649 8 OverwriteProtection = zc_get_config("zquest","overwrite_prevention",0)!=0;
23650 8 ImportMapBias = zc_get_config("zquest","import_map_bias",0);
23651
23652 8 KeyboardRepeatDelay = zc_get_config("zquest","keyboard_repeat_delay",300);
23653 8 KeyboardRepeatRate = zc_get_config("zquest","keyboard_repeat_rate",80);
23654
23655 // Frameskip = zc_get_config("zquest","frameskip",0); //todo: this is not actually supported yet.
23656 8 RequestedFPS = zc_get_config("zquest","fps",60);
23657
23658 // Autofill for Combo Page, Tile Page
23659 8 PreFillTileEditorPage = zc_get_config("zquest","PreFillTileEditorPage",0);
23660 8 PreFillComboEditorPage = zc_get_config("zquest","PreFillComboEditorPage",0);
23661
23662 8 pixeldb = zc_get_config("ZQ_GUI","bottom_8_pixels",0);
23663 8 infobg = zc_get_config("ZQ_GUI","info_text_bg",0);
23664
23665 8 large_merged_combopane = zc_get_config("ZQ_GUI","merge_cpane_large",0);
23666 8 compact_merged_combopane = zc_get_config("ZQ_GUI","merge_cpane_compact",1);
23667
23668 8 compact_square_panels = zc_get_config("ZQ_GUI","square_panels_compact",0);
23669
23670 8 large_zoomed_fav = zc_get_config("ZQ_GUI","zoom_fav_large",0);
23671 8 compact_zoomed_fav = zc_get_config("ZQ_GUI","zoom_fav_compact",1);
23672 8 large_zoomed_cmd = zc_get_config("ZQ_GUI","zoom_cmd_large",1);
23673 8 compact_zoomed_cmd = zc_get_config("ZQ_GUI","zoom_cmd_compact",1);
23674
23675
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(zc_get_config("gui","disable_window_resizing",0))
23676 all_set_resize_flag(false);
23677
23678 8 load_hotkeys();
23679
23680 #ifdef _WIN32
23681 zqUseWin32Proc = zc_get_config("zquest","zq_win_proc_fix",0);
23682
23683 #endif
23684
23685
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if (!render_timer_start())
23686 {
23687 Z_error_fatal("couldn't allocate timer");
23688 }
23689
23690 8 byte layermask = zc_get_config("zquest","layer_mask",0x7F);
23691 8 int32_t usefullscreen = zc_get_config("zquest","fullscreen",0);
23692 8 tempmode = (usefullscreen == 0 ? GFX_AUTODETECT_WINDOWED : GFX_AUTODETECT_FULLSCREEN);
23693
23694
2/2
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 8 times.
64 for(int32_t x=0; x<7; x++)
23695 {
23696 56 LayerMaskInt[x]=get_bit(&layermask,x);
23697 56 }
23698
23699 8 DuplicateAction[0] = zc_get_config("zquest","normal_duplicate_action",2);
23700 8 DuplicateAction[1] = zc_get_config("zquest","horizontal_duplicate_action",0);
23701 8 DuplicateAction[2] = zc_get_config("zquest","vertical_duplicate_action",0);
23702 8 DuplicateAction[3] = zc_get_config("zquest","both_duplicate_action",0);
23703 8 LeechUpdate = zc_get_config("zquest","leech_update",500);
23704 8 LeechUpdateTiles = zc_get_config("zquest","leech_update_tiles",1);
23705 8 OnlyCheckNewTilesForDuplicates = zc_get_config("zquest","only_check_new_tiles_for_duplicates",0);
23706 //gui_colorset = zc_get_config("zquest","gui_colorset",0);
23707
23708 8 strcpy(last_timed_save,zc_get_config("zquest","last_timed_save",""));
23709
23710 8 midi_volume = zc_get_config("zquest", "midi", 255);
23711
23712 8 abc_patternmatch = zc_get_config("zquest", "lister_pattern_matching", 1);
23713 8 NoScreenPreview = zc_get_config("zquest", "no_preview", 0);
23714
23715 8 monochrome_console = zc_get_config("CONSOLE","monochrome_debuggers",0)?1:0;
23716
23717 8 try_recovering_missing_scripts = 0;//zc_get_config("Compiler", "try_recovering_missing_scripts",0);
23718 //We need to remove all of the zeldadx refs to the config file for zquest.
23719
23720 8 set_keyboard_rate(KeyboardRepeatDelay,KeyboardRepeatRate);
23721
23722 8 is_compact = zc_get_config("ZQ_GUI","compact_mode",1);
23723 8 mapscreenbmp = nullptr;
23724 8 brushbmp = nullptr;
23725 8 brushscreen = nullptr;
23726 8 screen2 = nullptr;
23727 8 tmp_scr = nullptr;
23728 8 menu1 = nullptr;
23729 8 menu3 = nullptr;
23730
23731
2/2
✓ Branch 0 taken 10080 times.
✓ Branch 1 taken 8 times.
10088 for(int32_t i=0; i<MAXFAVORITECOMBOS; ++i)
23732 {
23733 10080 favorite_combos[i]=-1;
23734 10080 pool_combos[i].clear();
23735 10080 }
23736 8 FavoriteComboPage = 0;
23737 8 pool_dirty = true;
23738
23739
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(used_switch(argc,argv,"-d"))
23740 {
23741 set_debug(!strcmp(zquestpwd,zc_get_config("zquest","debug_this","")));
23742 }
23743
23744 8 zcmusic_init();
23745 8 zcmixer = zcmixer_create();
23746 1121 install_int_ex([](){ zcmusic_poll(); }, MSEC_TO_TIMER(25));
23747
23748 8 set_color_depth(8);
23749
23750 8 set_close_button_callback((void (*)()) hit_close_button);
23751
23752
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(used_switch(argc,argv,"-fullscreen"))
23753 {
23754 tempmode = GFX_AUTODETECT_FULLSCREEN;
23755 }
23756
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 else if(used_switch(argc,argv,"-windowed"))
23757 {
23758 tempmode=GFX_AUTODETECT_WINDOWED;
23759 }
23760
23761 8 zq_screen_w = LARGE_W;
23762 8 zq_screen_h = LARGE_H;
23763 8 window_width = zc_get_config("zquest","window_width",-1);
23764 8 window_height = zc_get_config("zquest","window_height",-1);
23765 8 auto [w, h] = zc_get_default_display_size(LARGE_W, LARGE_H, window_width, window_height);
23766
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 int32_t videofail = is_headless() ? 0 : (set_gfx_mode(tempmode,w,h,zq_screen_w,zq_screen_h));
23767
23768 //extra block here is intentional
23769
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(videofail!=0)
23770 {
23771 quit_game();
23772 allegro_exit();
23773 }
23774
23775 8 zalleg_create_window();
23776 8 Z_message("gfx mode set at -%d %dbpp %d x %d \n",
23777 8 tempmode, get_color_depth(), zq_screen_w, zq_screen_h);
23778
23779 8 set_window_title("ZC Editor");
23780
23781 8 load_size_poses();
23782
23783
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if (!is_headless())
23784 {
23785 // Just in case.
23786 while (!all_get_display()) {
23787 al_rest(1);
23788 }
23789
23790 al_resize_display(all_get_display(), w, h);
23791 }
23792
23793
23794 #ifndef __EMSCRIPTEN__
23795
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if (!all_get_fullscreen_flag() && !is_headless()) {
23796 al_resize_display(all_get_display(), w, h);
23797
23798 int window_w = al_get_display_width(all_get_display());
23799 int window_h = al_get_display_height(all_get_display());
23800
23801 int new_x = zc_get_config("zquest","window_x",0);
23802 int new_y = zc_get_config("zquest","window_y",0);
23803 if(zc_get_config("zquest","save_window_position",0) && (new_x || new_y))
23804 {
23805 //load saved position
23806 //already stored in new_x/new_y
23807 }
23808 else
23809 {
23810 //Get default position
23811 ALLEGRO_MONITOR_INFO info;
23812 al_get_monitor_info(0, &info);
23813
23814 int mw = (info.x2 - info.x1);
23815 int mh = (info.y2 - info.y1);
23816 new_x = mw / 2 - window_w / 2;
23817 new_y = mh / 2 - window_h / 2;
23818 //Don't spawn the window too far down (taskbar?)
23819 if(new_y + window_h > mh - 72)
23820 new_y = mh-72-window_h;
23821 }
23822 #ifdef ALLEGRO_MACOSX
23823 if (zc_get_config("zquest","save_window_position",0))
23824 al_set_window_position(all_get_display(), new_x, new_y);
23825 #else
23826 al_set_window_position(all_get_display(), new_x, new_y);
23827 #endif
23828 }
23829 #endif
23830
23831 8 position_mouse(zq_screen_w/2,zq_screen_h/2);
23832
23833 8 dmapbmp_small = create_bitmap_ex(8,65,33);
23834 8 dmapbmp_large = create_bitmap_ex(8,177,81);
23835
23836
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!screen2 || !tmp_scr || !menu1 || !menu3 || !dmapbmp_large || !dmapbmp_large || !brushbmp || !brushscreen)// || !brushshadowbmp )
23837 {
23838 Z_error_fatal("Failed to create system bitmaps!\n");
23839 return 1;
23840 }
23841
23842 8 int quick_assign_arg = used_switch(argc, argv, "-quick-assign");
23843
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 6 times.
8 if (quick_assign_arg > 0)
23844 {
23845 6 is_zq_replay_test = true;
23846 6 set_headless_mode();
23847
23848 6 int load_ret = load_quest(argv[quick_assign_arg + 1], false);
23849 6 bool success = load_ret == qe_OK;
23850
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if (!success)
23851 {
23852 printf("Failed to load quest: %d\n", load_ret);
23853 zq_exit(1);
23854 }
23855
23856 6 success = do_compile_and_slots(1, false);
23857
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if (!success)
23858 {
23859 printf("Failed to compile\n");
23860 zq_exit(1);
23861 }
23862
23863 6 success = save_quest(argv[quick_assign_arg + 1], false) == 0;
23864
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if (!success)
23865 {
23866 printf("Failed to save quest\n");
23867 zq_exit(1);
23868 }
23869
23870 6 zq_exit(0);
23871 6 }
23872
23873 8 int smart_assign_arg = used_switch(argc, argv, "-smart-assign");
23874
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if (smart_assign_arg > 0)
23875 {
23876 is_zq_replay_test = true;
23877 set_headless_mode();
23878
23879 int load_ret = load_quest(argv[smart_assign_arg + 1], false);
23880 bool success = load_ret == qe_OK;
23881 if (!success)
23882 {
23883 printf("Failed to load quest: %d\n", load_ret);
23884 zq_exit(1);
23885 }
23886
23887 success = do_compile_and_slots(2, false);
23888 if (!success)
23889 {
23890 printf("Failed to compile\n");
23891 zq_exit(1);
23892 }
23893
23894 success = save_quest(argv[smart_assign_arg + 1], false) == 0;
23895 if (!success)
23896 {
23897 printf("Failed to save quest\n");
23898 zq_exit(1);
23899 }
23900
23901 zq_exit(0);
23902 }
23903
23904 8 int export_strings_arg = used_switch(argc, argv, "-export-strings");
23905
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 1 times.
8 if (export_strings_arg > 0)
23906 {
23907
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (export_strings_arg + 3 > argc)
23908 {
23909 printf("%d\n", argc);
23910 printf("expected -export-strings input.qst output.tsv\n");
23911 zq_exit(1);
23912 }
23913
23914 1 is_zq_replay_test = true;
23915 1 set_headless_mode();
23916
23917 1 int load_ret = load_quest(argv[export_strings_arg + 1], false);
23918 1 bool success = load_ret == qe_OK;
23919
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (!success)
23920 {
23921 printf("Failed to load quest: %d\n", load_ret);
23922 zq_exit(1);
23923 }
23924
23925 1 success = save_strings_tsv(argv[export_strings_arg + 2]);
23926
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (!success)
23927 {
23928 printf("Failed to export strings\n");
23929 zq_exit(1);
23930 }
23931
23932 1 zq_exit(0);
23933 1 }
23934
23935
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if (!is_headless())
23936 {
23937 zc_set_palette(asset_pal);
23938 get_palette(RAMpal);
23939 load_colorset(gui_colorset);
23940 zc_set_palette(RAMpal);
23941 clear_to_color(screen,vc(0));
23942 }
23943
23944 8 zScript = string();
23945 8 strcpy(zScriptBytes, "0 Bytes in Buffer");
23946
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 8 times.
20 for(int32_t i=0; i<MOUSE_BMP_MAX; i++)
23947 {
23948
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 12 times.
60 for(int32_t j=0; j<4; j++)
23949 {
23950 48 mouse_bmp[i][j] = NULL;
23951 48 mouse_bmp_1x[i][j] = NULL;
23952 48 }
23953 12 }
23954 8 load_mice();
23955 8 gui_mouse_focus=0;
23956 8 MouseSprite::set(ZQM_NORMAL);
23957 8 render_zq(); // Ensure the rendering bitmaps are setup.
23958
23959 #ifdef __EMSCRIPTEN__
23960 em_mark_ready_status();
23961 #endif
23962
23963 8 load_icons();
23964
23965 8 bool load_last_timed_save=false;
23966
23967 8 load_recent_quests();
23968 8 refresh_recent_menu();
23969 //clearConsole();
23970
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8 if((last_timed_save[0]!=0)&&(exists(last_timed_save)))
23971 {
23972 if(jwin_alert("ZQuest","It appears that ZQuest crashed last time.","Would you like to load the last timed save?",NULL,"&Yes","&No",'y','n',get_zc_font(font_lfont))==1)
23973 {
23974 int32_t ret = load_quest(last_timed_save);
23975
23976 if(ret == qe_OK)
23977 {
23978 strcpy(filepath,last_timed_save);
23979 load_last_timed_save=true;
23980 saved=false;
23981 }
23982 else
23983 {
23984 jwin_alert("Error","Unable to reload the last timed save.",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
23985 }
23986 }
23987 }
23988
23989
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 1 times.
8 if(!load_last_timed_save)
23990 {
23991 1 strcpy(filepath,zc_get_config("zquest",last_quest_name,""));
23992
23993
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if(argc>1 && argv[1][0]!='-')
23994 {
23995 int32_t ret = load_quest(argv[1]);
23996
23997 if(ret == qe_OK)
23998 {
23999 first_save=true;
24000 strcpy(filepath,argv[1]);
24001 refresh(rALL);
24002 }
24003 }
24004
2/8
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1 else if(OpenLastQuest&&filepath[0]&&exists(filepath)&&!used_switch(argc,argv,"-new"))
24005 {
24006 int32_t ret = load_quest(filepath);
24007
24008 if(ret == qe_OK)
24009 {
24010 first_save=true;
24011 refresh(rALL);
24012 }
24013 else
24014 {
24015 filepath[0]=temppath[0]=0;
24016 first_save=false;
24017 }
24018 }
24019 else
24020 {
24021
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (onNew() == D_CLOSE)
24022 {
24023 1 Z_message("User canceled creating new quest, closing.\n");
24024 1 exit(0);
24025 }
24026
24027 //otherwise the blank quest gets the name of the last loaded quest... not good! -DD
24028 filepath[0]=temppath[0]=0;
24029 first_save=false;
24030 }
24031 }
24032
24033
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if(used_switch(argc,argv,"-q"))
24034 {
24035 Z_message("-q switch used, quitting program.\n");
24036 zq_exit(0);
24037 }
24038
24039
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 for(int32_t x=0; x<MAXITEMS; x++)
24040 {
24041 lens_hint_item[x][0]=0;
24042 lens_hint_item[x][1]=0;
24043 }
24044
24045
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 for(int32_t x=0; x<MAXWPNS; x++)
24046 {
24047 lens_hint_weapon[x][0]=0;
24048 lens_hint_weapon[x][1]=0;
24049 }
24050
24051 7 load_selections();
24052 7 load_arrows();
24053 7 clear_to_color(menu1,vc(0));
24054 7 DIALOG_PLAYER *player2=init_dialog(dialogs,-1);
24055
24056 7 get_palette(RAMpal);
24057
24058 7 rgb_map = &zq_rgb_table;
24059
24060 #ifdef __EMSCRIPTEN__
24061 {
24062 int qs_map = EM_ASM_INT({
24063 return new URL(location.href).searchParams.get('map') ?? -1;
24064 });
24065 int qs_screen = EM_ASM_INT({
24066 return new URL(location.href).searchParams.get('screen') ?? -1;
24067 });
24068 if (qs_map != -1 && qs_screen != -1) {
24069 Map.setCurrMap(qs_map);
24070 Map.setCurrScr(qs_screen);
24071 }
24072 }
24073 #endif
24074
24075 // setup_combo_animations();
24076 7 pause_refresh = false;
24077 7 refresh_pal();
24078 7 refresh(rALL);
24079
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 for(int q = 0; q < brush_width_menu.size(); ++q)
24080 brush_width_menu.at(q)->select(q==0);
24081
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 for(int q = 0; q < brush_height_menu.size(); ++q)
24082 brush_height_menu.at(q)->select(q==0);
24083 7 set_filltype(1);
24084
24085 7 rebuild_trans_table();
24086
24087
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if (!is_headless())
24088 {
24089 set_display_switch_mode(SWITCH_BACKGROUND);
24090 set_display_switch_callback(SWITCH_OUT, switch_out);
24091 set_display_switch_callback(SWITCH_IN, switch_in);
24092 }
24093
24094
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!update_dialog(player2))
24095 exiting_program = true;
24096 //clear_keybuf();
24097 7 media_menu.disable_uid(MENUID_MEDIA_CHANGETRACK, true);
24098 7 disable_hotkey(ZQKEY_CHANGE_TRACK, true);
24099
24100 7 fix_drawing_mode_menu();
24101
24102
24103 #ifdef _WIN32
24104
24105 if(zqUseWin32Proc != FALSE)
24106 {
24107 al_trace("Config file warning: \"zq_win_proc_fix\" enabled switch found. This can cause crashes on some computers.\n");
24108 win32data.zqSetDefaultThreadPriority(0);
24109 win32data.zqSetCustomCallbackProc(al_get_win_window_handle(all_get_display()));
24110 }
24111
24112 #endif
24113
24114 7 time(&auto_save_time_start);
24115
24116 7 FFCore.init();
24117 7 ZQincludePaths = FFCore.includePaths;
24118
24119 7 Map.setCopyFFC(-1); //Do not have an initial ffc on the clipboard.
24120 7 brush_menu.select_uid(MENUID_BRUSH_AUTOBRUSH, AutoBrush);
24121 7 brush_menu.disable_uid(MENUID_BRUSH_WIDTH, AutoBrush);
24122 7 brush_menu.disable_uid(MENUID_BRUSH_HEIGHT, AutoBrush);
24123 7 brush_menu.select_uid(MENUID_BRUSH_COMBOBRUSH, ComboBrush);
24124 7 brush_menu.select_uid(MENUID_BRUSH_FLOATBRUSH, FloatBrush);
24125
24126 7 call_foo_dlg();
24127
24128 7 application_has_loaded = true;
24129
24130
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 while(!exiting_program)
24131 {
24132 handle_sentry_tags();
24133
24134 #ifdef _WIN32
24135 if(zqUseWin32Proc != FALSE)
24136 win32data.Update(Frameskip); //experimental win32 fixes
24137 #endif
24138 check_autosave();
24139 ++alignment_arrow_timer;
24140
24141 if(alignment_arrow_timer>63)
24142 {
24143 alignment_arrow_timer=0;
24144 }
24145 ++frame;
24146
24147 file_menu.disable_uid(MENUID_FILE_SAVE, saved||disable_saving||OverwriteProtection);
24148 file_menu.disable_uid(MENUID_FILE_REVERT, saved||disable_saving||OverwriteProtection);
24149 file_menu.disable_uid(MENUID_FILE_SAVEAS, disable_saving);
24150
24151 fixtools_menu.disable_uid(MENUID_FIXTOOL_OLDSTRING,
24152 !(get_qr(qr_OLD_STRING_EDITOR_MARGINS)
24153 ||get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)));
24154
24155 edit_menu.disable_uid(MENUID_EDIT_UNDO, !Map.CanUndo());
24156 edit_menu.disable_uid(MENUID_EDIT_REDO, !Map.CanRedo());
24157
24158 bool canpaste = Map.CanPaste();
24159 edit_menu.disable_uid(MENUID_EDIT_PASTE, !canpaste);
24160 edit_menu.disable_uid(MENUID_EDIT_PASTEALL, !canpaste);
24161 edit_menu.disable_uid(MENUID_EDIT_ADVPASTE, !canpaste);
24162 edit_menu.disable_uid(MENUID_EDIT_SPECPASTE, !canpaste);
24163 rc_menu_screen.disable_uid(MENUID_RCSCREEN_PASTE, !canpaste);
24164 rc_menu_screen.disable_uid(MENUID_RCSCREEN_ADVPASTE, !canpaste);
24165 rc_menu_screen.disable_uid(MENUID_RCSCREEN_SPECPASTE, !canpaste);
24166 for(MenuItem& mit : paste_menu.inner())
24167 mit.disable(!canpaste);
24168 for(MenuItem& mit : paste_item_menu.inner())
24169 mit.disable(!canpaste);
24170
24171 edit_menu.disable_uid(MENUID_EDIT_COPY, !(Map.CurrScr()->valid&mVALID));
24172 edit_menu.disable_uid(MENUID_EDIT_DELETE, !(Map.CurrScr()->valid&mVALID));
24173
24174 // Are some things selected?
24175 view_menu.select_uid(MENUID_VIEW_WALKABILITY, Flags&cWALK);
24176 view_menu.select_uid(MENUID_VIEW_FLAGS, Flags&cFLAGS);
24177 view_menu.select_uid(MENUID_VIEW_CSET, Flags&cCSET);
24178 view_menu.select_uid(MENUID_VIEW_TYPES, Flags&cCTYPE);
24179 view_menu.select_uid(MENUID_VIEW_INFO, ShowInfo);
24180 view_menu.select_uid(MENUID_VIEW_SQUARES, ShowSquares);
24181 view_menu.select_uid(MENUID_VIEW_FFCS, ShowFFCs);
24182 view_menu.select_uid(MENUID_VIEW_SCRIPTNAMES, ShowFFScripts);
24183 view_menu.select_uid(MENUID_VIEW_GRID, ShowGrid);
24184 view_menu.select_uid(MENUID_VIEW_SCREENGRID, ShowScreenGrid);
24185 view_menu.select_uid(MENUID_VIEW_REGIONGRID, ShowRegionGrid);
24186 view_menu.select_uid(MENUID_VIEW_CURSCROUTLINE, ShowCurScreenOutline);
24187 view_menu.select_uid(MENUID_VIEW_DARKNESS, get_qr(qr_NEW_DARKROOM) && (Flags&cNEWDARK));
24188 view_menu.select_uid(MENUID_VIEW_L2BG, ViewLayer2BG);
24189 view_menu.select_uid(MENUID_VIEW_L3BG, ViewLayer3BG);
24190 view_menu.select_uid(MENUID_VIEW_LAYERHIGHLIGHT, ActiveLayerHighlight);
24191
24192 maps_menu.disable_uid(MENUID_MAPS_NEXT, !map_count || Map.getCurrMap() >= map_count);
24193 maps_menu.disable_uid(MENUID_MAPS_PREV, Map.getCurrMap()<=0);
24194
24195 etc_menu.disable_uid(MENUID_ETC_VIDMODE, isFullScreen()==1);
24196 etc_menu.select_uid(MENUID_ETC_FULLSCREEN, isFullScreen()==1);
24197
24198 if(!update_dialog(player2))
24199 exiting_program = true;
24200
24201 //clear_keybuf();
24202 handle_close_btn_quit();
24203 }
24204
24205 7 zq_exit(0);
24206 7 return 0;
24207 }
24208 END_OF_MAIN()
24209
24210 11 void zq_exit(int code)
24211 {
24212 11 set_is_exiting();
24213 11 parser_console.kill();
24214 11 killConsole();
24215
24216 11 quit_game();
24217 11 allegro_exit();
24218 11 exit(code);
24219 }
24220
24221 56 void init_bitmap(BITMAP** bmp, int32_t w, int32_t h)
24222 {
24223
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
56 if(*bmp)
24224 destroy_bitmap(*bmp);
24225 56 *bmp = create_bitmap_ex(8,w,h);
24226 56 clear_bitmap(*bmp);
24227 56 }
24228 8 void load_size_poses()
24229 {
24230 8 ttip_uninstall_all();
24231
24232 8 FONT* favcmdfont = get_custom_font(CFONT_FAVCMD);
24233 8 FONT* guifont = get_custom_font(CFONT_GUI);
24234
24235 8 d_nbmenu_proc(MSG_START, &dialogs[0], 0);
24236
24237 8 commands_list.xscale = command_buttonwidth;
24238 8 commands_list.yscale = 10+text_height(favcmdfont);
24239
24240 8 auto drawmode_wid = 64;
24241
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 8 times.
56 for(auto q = 0; q < dm_max; ++q)
24242 {
24243 48 auto wid = text_length(guifont, dm_names[q]);
24244
1/2
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
48 if(wid > drawmode_wid)
24245 drawmode_wid = wid;
24246 48 }
24247
24248 //Main GUI objects
24249
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(is_compact)
24250 {
24251 8 num_combo_cols = 2;
24252 8 combo_col_scale = 16;
24253
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(compact_merged_combopane)
24254 {
24255 8 num_combo_cols = 1;
24256 8 combo_col_scale = 32;
24257 8 }
24258
24259 8 mapscreen_x=0;
24260 8 mapscreen_y=dialogs[0].h;
24261 8 mapscreen_screenunit_scale=3;
24262 8 mapscreen_single_scale = (double)mapscreen_screenunit_scale / Map.getViewSize();
24263 8 showedges=0;
24264 8 showallpanels=0;
24265
24266 8 blackout_color=8;
24267
24268 8 auto mapscr_wid = (((showedges?2:0)+16)*16*mapscreen_screenunit_scale);
24269 8 combolist_window.w=zq_screen_w-mapscr_wid;
24270 8 combolist_window.x=zq_screen_w-combolist_window.w;
24271
24272 8 favorites_window.x=combolist_window.x;
24273 8 favorites_window.w=combolist_window.w;
24274 8 favorites_window.h=136;
24275 8 favorites_window.y=zq_screen_h-favorites_window.h;
24276
24277 8 combolist_window.y=0;
24278 8 combolist_window.h=favorites_window.y-combolist_window.y;
24279
24280 8 combo_preview.x=zq_screen_w-32-8;
24281 8 combo_preview.y=combolist_window.y+6;
24282 8 combo_preview.w=32;
24283 8 combo_preview.h=32;
24284 8 combo_preview2.clear();
24285
24286 8 auto col_wid = 4*combo_col_scale;
24287 8 auto cols_wid = col_wid * num_combo_cols;
24288 8 auto cols_spacing = (combolist_window.w-cols_wid)/(num_combo_cols+1);
24289
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 8 times.
16 for(auto q = 0; q < num_combo_cols; ++q)
24290 {
24291 8 combolist[q].x=combolist_window.x+(cols_spacing*(q+1))+(col_wid*q);
24292 8 combolist[q].y=combolist_window.y+54;
24293 8 combolist[q].w=4;
24294 8 combolist[q].h=compact_merged_combopane ? 15 : 30;
24295 8 combolist[q].xscale = combo_col_scale;
24296 8 combolist[q].yscale = combo_col_scale;
24297
24298 8 comboaliaslist[q].x = combolist[q].x;
24299 8 comboaliaslist[q].y = combolist[q].y;
24300 8 comboaliaslist[q].w = 4;
24301 8 comboaliaslist[q].h = compact_merged_combopane ? 13 : 26;
24302 8 comboaliaslist[q].xscale = combo_col_scale;
24303 8 comboaliaslist[q].yscale = combo_col_scale;
24304
24305 8 combolistscrollers[q].w=2;
24306 8 combolistscrollers[q].h=1;
24307 8 combolistscrollers[q].xscale=11;
24308 8 combolistscrollers[q].yscale=11;
24309 8 combolistscrollers[q].x=combolist[q].x+(combolist[q].w*combolist[q].xscale/2)-11;
24310 8 combolistscrollers[q].y=combolist[q].y-combolistscrollers[q].th()-3;
24311 8 }
24312
24313 8 comboalias_preview.x=zq_screen_w-((combolist_window.w+64)/2);
24314 8 comboalias_preview.h=64;
24315 8 comboalias_preview.y=favorites_window.y-comboalias_preview.h-8;
24316 8 comboalias_preview.w=64;
24317
24318 8 combo_merge_btn.w = 20;
24319 8 combo_merge_btn.h = 20;
24320 8 combo_merge_btn.x = zq_screen_w-(combolist_window.w+combo_merge_btn.w)/2;
24321 8 combo_merge_btn.y = combolist[0].y-combo_merge_btn.h;
24322
24323
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(num_combo_cols == 1)
24324 {
24325 8 combolistscrollers[0].x += 34;
24326 8 }
24327 8 drawmode_btn.x = combolist_window.x-drawmode_wid;
24328 8 drawmode_btn.y = 0;
24329 8 drawmode_btn.w = drawmode_wid;
24330 8 drawmode_btn.h = mapscreen_y;
24331
24332 8 compactbtn.w = text_length(guifont,"> Compact")+10;
24333 8 compactbtn.x = drawmode_btn.x-compactbtn.w;
24334 8 compactbtn.y = drawmode_btn.y;
24335 8 compactbtn.h = drawmode_btn.h;
24336
24337 8 zoominbtn.w = text_length(guifont,"+")+10;
24338 8 zoominbtn.x = compactbtn.x-zoominbtn.w;
24339 8 zoominbtn.y = compactbtn.y;
24340 8 zoominbtn.h = compactbtn.h;
24341
24342 8 zoomoutbtn.w = text_length(guifont,"-")+10;
24343 8 zoomoutbtn.x = zoominbtn.x-zoomoutbtn.w;
24344 8 zoomoutbtn.y = compactbtn.y;
24345 8 zoomoutbtn.h = compactbtn.h;
24346
24347
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 8 times.
80 for(int32_t i=0; i<=8; i++)
24348 {
24349 72 map_page_bar[i].w = 48;
24350 72 map_page_bar[i].x = mapscreen_x+(i*48);
24351 72 map_page_bar[i].y = mapscreen_y+(11*16*mapscreen_screenunit_scale);
24352 72 map_page_bar[i].h = text_height(guifont)+12;
24353 72 }
24354
24355 8 minimap.w=7+48*3;
24356 8 minimap.h=16+27*3;
24357
24358 8 layer_panel.x=map_page_bar[6].x;
24359 8 layer_panel.y=map_page_bar[0].y;
24360 8 layer_panel.w=combolist_window.x - layer_panel.x;
24361 8 layer_panel.h=map_page_bar[0].h;
24362 8 layerpanel_buttonwidth = 51;
24363 8 layerpanel_buttonheight = layer_panel.h;
24364 8 layerpanel_checkbox_hei = layerpanel_buttonheight-4;
24365 8 layerpanel_checkbox_wid = 15;
24366
24367 8 minimap.x=3;
24368 8 minimap.y=layer_panel.y+layer_panel.h+4;
24369
24370 8 real_minimap.x = minimap.x+3;
24371 8 real_minimap.y = minimap.y+5;
24372 8 real_minimap.w = 16;
24373 8 real_minimap.h = 9;
24374 8 real_minimap.xscale = 9;
24375 8 real_minimap.yscale = 9;
24376 8 real_minimap.fw = real_minimap.xscale*8;
24377 8 real_minimap.fh = real_minimap.yscale*8;
24378
24379 8 int upscale_mm = 3;
24380 8 int xwid = real_minimap.tw()*(upscale_mm-1);
24381 8 int xhei = real_minimap.th()*(upscale_mm-1);
24382 8 minimap_zoomed.set(minimap.x, minimap.y-xhei, minimap.w+xwid, minimap.h+xhei+4);
24383 8 real_minimap_zoomed.set(minimap_zoomed.x+3, minimap_zoomed.y+5, real_minimap.w, real_minimap.h, real_minimap.xscale*upscale_mm, real_minimap.yscale*upscale_mm);
24384 8 real_minimap_zoomed.fw = real_minimap_zoomed.xscale*8;
24385 8 real_minimap_zoomed.fh = real_minimap_zoomed.yscale*8;
24386
24387 8 screrrorpos.x = combolist_window.x - 3;
24388 8 screrrorpos.y = layer_panel.y - 16;
24389
24390 8 mouse_scroll_h=10;
24391
24392 8 favorites_list.x=favorites_window.x+8;
24393 8 favorites_list.y=favorites_window.y+16;
24394 8 favorites_list.xscale = 16;
24395 8 favorites_list.yscale = 16;
24396 8 favorites_list.w=(favorites_window.w-16)/favorites_list.xscale;
24397 8 favorites_list.h=(favorites_window.h-24)/favorites_list.yscale;
24398
24399 8 commands_list.w=4;
24400
24401 8 int bh = commands_list.yscale;
24402 8 int bw = 26;
24403 8 commands_window.w=commands_list.w*commands_list.xscale+10+bw;
24404 8 commands_window.x=combolist_window.x-commands_window.w;
24405 8 commands_window.y=layer_panel.y+layer_panel.h;
24406 8 commands_window.h=zq_screen_h-commands_window.y;
24407 8 int bx = commands_window.x+2;
24408
24409 8 commands_list.y=commands_window.y+4;
24410 8 commands_list.h=(zq_screen_h - commands_list.y) / commands_list.yscale;
24411 8 commands_list.x=bx+bw;
24412
24413 8 commands_zoombtn.w = bw;
24414 8 commands_zoombtn.h = bh;
24415 8 commands_zoombtn.x = bx;
24416 8 commands_zoombtn.y = commands_list.y;
24417
24418 8 commands_infobtn.w = bw;
24419 8 commands_infobtn.h = bh;
24420 8 commands_infobtn.x = bx;
24421 8 commands_infobtn.y = commands_zoombtn.y + commands_infobtn.h;
24422
24423 8 commands_x.w = bw;
24424 8 commands_x.h = bh;
24425 8 commands_x.x = bx;
24426 8 commands_x.y = commands_infobtn.y + commands_x.h;
24427
24428 8 commands_txt.clear();
24429
24430 8 main_panel.x = 0;
24431 8 main_panel.y = layer_panel.y+layer_panel.h;
24432 8 main_panel.w = commands_window.x - main_panel.x;
24433 8 main_panel.h = 76+32;
24434 8 preview_panel = main_panel;
24435 8 preview_panel.x = 0;
24436 8 preview_panel.w = commands_window.x - preview_panel.x;
24437
24438 8 preview_text.x = preview_panel.x+3;
24439 8 preview_text.y = preview_panel.y+3;
24440 8 preview_text.w = 2;
24441 8 preview_text.h = 6;
24442 8 preview_text.xscale = 10;
24443 8 preview_text.yscale = text_height(get_zc_font(font_lfont_l));
24444
24445 8 panel_align = 1;
24446 8 int swapbtnw = 32, swapbtnh = 20;
24447 8 int swapbtnx = main_panel.x+main_panel.tw()-swapbtnw;
24448 8 squarepanel_swap_btn.set(swapbtnx, zq_screen_h-swapbtnh, swapbtnw, swapbtnh);
24449
24450 8 int sqx = minimap.x+minimap.tw();
24451 8 squares_panel.set(sqx,main_panel.y,main_panel.tw()-sqx,main_panel.th());
24452
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(compact_square_panels)
24453 {
24454 int cmpy = main_panel.y+(main_panel.th()/2);
24455 squarepanel_up_btn.set(swapbtnx, cmpy-swapbtnh, swapbtnw, swapbtnh);
24456 squarepanel_down_btn.set(swapbtnx, cmpy, swapbtnw, swapbtnh);
24457
24458 txtoffs_single.x = 18;
24459 txtoffs_single.y = 36;
24460 txtoffs_double_1.x = 18;
24461 txtoffs_double_1.y = 36;
24462 txtoffs_double_2.x = 18;
24463 txtoffs_double_2.y = 36 + text_height(get_custom_font(CFONT_GUI));
24464
24465 //Clear them all- if they stay cleared, they are invisible.
24466 itemsqr_pos.clear();
24467 stairsqr_pos.clear();
24468 warparrival_pos.clear();
24469 flagsqr_pos.clear();
24470 enemy_prev_pos.clear();
24471 for(int q = 0; q < 4; ++q)
24472 warpret_pos[q].clear();
24473
24474 int sqr_x1 = sqx+12;
24475 int sqr_y1 = main_panel.y+12;
24476 int sqr_xoffs = (16*2)+4 + 12;
24477 switch(compact_active_panel)
24478 {
24479 case 0: //Warp Squares
24480 {
24481 int x = sqr_x1;
24482 for(int q = 0; q < 4; ++q)
24483 {
24484 warpret_pos[q].set(x,sqr_y1,(16*2)+4,(16*2)+4);
24485 x += sqr_xoffs;
24486 }
24487 break;
24488 }
24489 case 1: //Other Squares
24490 {
24491 itemsqr_pos.set(sqr_x1+(sqr_xoffs*0), sqr_y1, (16*2)+4,(16*2)+4);
24492 stairsqr_pos.set(sqr_x1+(sqr_xoffs*1), sqr_y1, (16*2)+4,(16*2)+4);
24493 warparrival_pos.set(sqr_x1+(sqr_xoffs*2), sqr_y1, (16*2)+4,(16*2)+4);
24494 flagsqr_pos.set(sqr_x1+(sqr_xoffs*3), sqr_y1, (16*2)+4,(16*2)+4);
24495 break;
24496 }
24497 case 2: //Enemy Preview
24498 {
24499 enemy_prev_pos.set(sqr_x1, sqr_y1, 5, 2, 32, 32);
24500 break;
24501 }
24502 }
24503 }
24504 else
24505 {
24506 8 squarepanel_up_btn.clear();
24507 8 squarepanel_down_btn.clear();
24508 8 txtoffs_single.x = 10;
24509 8 txtoffs_single.y = 22;
24510 8 txtoffs_double_1.x = 10;
24511 8 txtoffs_double_1.y = 22;
24512 8 txtoffs_double_2.x = 10;
24513 8 txtoffs_double_2.y = 30;
24514
24515
24516 8 int sqr_x1 = sqx+24;
24517 8 int sqr_y1 = main_panel.y+12;
24518 8 int sqr_y2 = sqr_y1+42;
24519 8 int sqr_xdist = 32;
24520 8 itemsqr_pos.set(sqr_x1+(sqr_xdist*0),sqr_y1,20,20);
24521 8 stairsqr_pos.set(sqr_x1+(sqr_xdist*1),sqr_y1,20,20);
24522 8 warparrival_pos.set(sqr_x1+(sqr_xdist*2),sqr_y1,20,20);
24523 8 flagsqr_pos.set(sqr_x1+(sqr_xdist*3),sqr_y1,20,20);
24524
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 8 times.
40 for(auto q = 0; q < 4; ++q)
24525 {
24526 32 warpret_pos[q].set(sqr_x1+(sqr_xdist*q),sqr_y2,20,20);
24527 32 }
24528 8 enemy_prev_pos.set(sqr_x1+(sqr_xdist*4), sqr_y1, 4, 3, 16, 16);
24529 8 enemy_prev_pos.fw = enemy_prev_pos.xscale*2;
24530 8 enemy_prev_pos.fh = enemy_prev_pos.yscale*2;
24531 }
24532
24533 8 auto& last_alias_list = comboaliaslist[num_combo_cols-1];
24534 8 combopool_preview.x=comboaliaslist[0].x;
24535 8 combopool_preview.y=last_alias_list.y+(last_alias_list.h*last_alias_list.yscale)+16;
24536 8 combopool_preview.w=(last_alias_list.x+(last_alias_list.w*last_alias_list.xscale))-comboaliaslist[0].x;
24537 8 combopool_preview.h=zq_screen_h-8-combopool_preview.y;
24538 8 combopool_preview.w -= combopool_preview.w%16;
24539 8 combopool_preview.h -= combopool_preview.h%16;
24540
24541 8 FONT* tfont = get_zc_font(font_lfont_l);
24542 8 combopool_prevbtn.w = text_length(tfont, "Unweighted")+10;
24543 8 combopool_prevbtn.h = 11;
24544 8 combopool_prevbtn.x = combopool_preview.x;
24545 8 combopool_prevbtn.y = combopool_preview.y-combopool_prevbtn.h;
24546
24547 8 mappage_count = 6;
24548
24549 8 txfont = get_zc_font(font_lfont_l);
24550 8 combo_preview_text1.set(combo_preview.x-5,combo_preview.y,1,3,1,text_height(txfont));
24551 8 combo_preview_text2.clear();
24552
24553 8 favorites_x.w = 17;
24554 8 favorites_infobtn.w = 17;
24555 8 favorites_zoombtn.w = 17;
24556 8 favorites_pgleft.w = 17;
24557 8 favorites_pgright.w = 17;
24558 8 }
24559 else
24560 {
24561 num_combo_cols = 4;
24562 combo_col_scale = 16;
24563 if(large_merged_combopane)
24564 {
24565 num_combo_cols = 2;
24566 combo_col_scale = 32;
24567 }
24568
24569 mapscreen_x=0;
24570 mapscreen_y=dialogs[0].h;
24571 mapscreen_screenunit_scale=2;
24572 mapscreen_single_scale = (double)mapscreen_screenunit_scale / Map.getViewSize();
24573 showedges=Map.getViewSize() <= 2 ? 1 : 0;
24574 showallpanels=0;
24575
24576 blackout_color=8;
24577
24578 favorites_window.h=136;
24579 favorites_window.y=zq_screen_h-favorites_window.h;
24580
24581 auto mapscr_wid = (((2)+16)*16*mapscreen_screenunit_scale);
24582 combolist_window.w=zq_screen_w-mapscr_wid;
24583 combolist_window.x=zq_screen_w-combolist_window.w;
24584 combolist_window.y=0;
24585 combolist_window.h=favorites_window.y-combolist_window.y;
24586
24587 favorites_window.x=combolist_window.x;
24588 favorites_window.w=combolist_window.w;
24589
24590 combo_preview.x=(zq_screen_w-(combolist_window.w/2))-40;
24591 combo_preview.y=combolist_window.y+6;
24592 combo_preview.w=32;
24593 combo_preview.h=32;
24594 combo_preview2 = combo_preview;
24595 combo_preview2.x += 48;
24596
24597 auto col_wid = 4*combo_col_scale;
24598 auto cols_wid = col_wid * num_combo_cols;
24599 auto cols_spacing = (combolist_window.w-cols_wid)/(num_combo_cols+1);
24600 for(auto q = 0; q < num_combo_cols; ++q)
24601 {
24602 combolist[q].x=combolist_window.x+(cols_spacing*(q+1))+(col_wid*q);
24603 combolist[q].y=combolist_window.y+60;
24604 combolist[q].w=4;
24605 combolist[q].h=large_merged_combopane ? 15 : 30;
24606 combolist[q].xscale = combo_col_scale;
24607 combolist[q].yscale = combo_col_scale;
24608
24609 comboaliaslist[q].x=combolist[q].x;
24610 comboaliaslist[q].y=combolist[q].y;
24611 comboaliaslist[q].w=4;
24612 comboaliaslist[q].h=large_merged_combopane ? 12 : 25;
24613 comboaliaslist[q].xscale = combo_col_scale;
24614 comboaliaslist[q].yscale = combo_col_scale;
24615
24616 combolistscrollers[q].w=2;
24617 combolistscrollers[q].h=1;
24618 combolistscrollers[q].xscale=11;
24619 combolistscrollers[q].yscale=11;
24620 combolistscrollers[q].x=combolist[q].x+(combolist[q].w*combolist[q].xscale/2)-11;
24621 combolistscrollers[q].y=combolist[q].y-combolistscrollers[q].th()-2;
24622 }
24623
24624 comboalias_preview.x=zq_screen_w-((combolist_window.w+64)/2);
24625 comboalias_preview.h=64;
24626 comboalias_preview.w=64;
24627 comboalias_preview.y=favorites_window.y-comboalias_preview.h-8;
24628
24629 combo_merge_btn.w = 20;
24630 combo_merge_btn.h = 20;
24631 combo_merge_btn.x = zq_screen_w-(combolist_window.w+combo_merge_btn.w)/2;
24632 combo_merge_btn.y = combolist[0].y-combo_merge_btn.h;
24633 squarepanel_swap_btn.clear();
24634 squarepanel_up_btn.clear();
24635 squarepanel_down_btn.clear();
24636
24637 drawmode_btn.x = combolist_window.x-drawmode_wid;
24638 drawmode_btn.y = 0;
24639 drawmode_btn.w = drawmode_wid;
24640 drawmode_btn.h = mapscreen_y;
24641
24642 compactbtn.w = text_length(guifont,"> Compact")+10;
24643 compactbtn.x = drawmode_btn.x-compactbtn.w;
24644 compactbtn.y = drawmode_btn.y;
24645 compactbtn.h = drawmode_btn.h;
24646
24647 zoominbtn.w = text_length(guifont,"+")+10;
24648 zoominbtn.x = compactbtn.x-zoominbtn.w;
24649 zoominbtn.y = compactbtn.y;
24650 zoominbtn.h = compactbtn.h;
24651
24652 zoomoutbtn.w = text_length(guifont,"-")+10;
24653 zoomoutbtn.x = zoominbtn.x-zoomoutbtn.w;
24654 zoomoutbtn.y = compactbtn.y;
24655 zoomoutbtn.h = compactbtn.h;
24656
24657 for(int32_t i=0; i<=8; i++)
24658 {
24659 map_page_bar[i].x = mapscreen_x+(i*16*2*mapscreen_screenunit_scale);
24660 map_page_bar[i].y = mapscreen_y+((13)*16*mapscreen_screenunit_scale);
24661 map_page_bar[i].w = 64;
24662 map_page_bar[i].h = text_height(guifont)+12;
24663 }
24664
24665 minimap.w=7+48*3;
24666 minimap.h=16+27*3;
24667
24668 layer_panel.x=map_page_bar[0].x;
24669 layer_panel.y=map_page_bar[0].y+map_page_bar[0].h;
24670 layer_panel.w=map_page_bar[8].x+map_page_bar[8].w;
24671 layer_panel.h=text_height(guifont)+8;
24672 layerpanel_buttonwidth = 58;
24673 layerpanel_buttonheight = layer_panel.h;
24674 layerpanel_checkbox_hei = layerpanel_buttonheight-4;
24675 layerpanel_checkbox_wid = 14;
24676
24677 commands_list.w=4;
24678 commands_window.w=commands_list.w*commands_list.xscale+16;
24679 commands_window.x=combolist_window.x-commands_window.w;
24680 commands_window.y=layer_panel.y+layer_panel.h;
24681 commands_window.h=zq_screen_h-commands_window.y;
24682
24683 //buttons panel
24684 main_panel.x = 0;
24685 main_panel.y = layer_panel.y+layer_panel.h;
24686 main_panel.w = commands_window.x - main_panel.x;
24687 main_panel.h = zq_screen_h - main_panel.y;
24688 preview_panel = main_panel;
24689
24690 preview_text.x = preview_panel.x+3;
24691 preview_text.y = preview_panel.y+3;
24692 preview_text.w = 1;
24693 preview_text.h = 12;
24694 preview_text.xscale = 10;
24695 preview_text.yscale = text_height(get_zc_font(font_lfont_l));
24696
24697 minimap.x=3;
24698 minimap.y=main_panel.y+4;
24699
24700 real_minimap.x = minimap.x+3;
24701 real_minimap.y = minimap.y+5;
24702 real_minimap.w = 16;
24703 real_minimap.h = 9;
24704 real_minimap.xscale = 9;
24705 real_minimap.yscale = 9;
24706 real_minimap.fw = real_minimap.xscale*8;
24707 real_minimap.fh = real_minimap.yscale*8;
24708
24709 int upscale_mm = 4;
24710 int xwid = real_minimap.tw()*(upscale_mm-1);
24711 int xhei = real_minimap.th()*(upscale_mm-1);
24712 int zh = minimap.h+xhei+4;
24713 minimap_zoomed.set(minimap.x, zq_screen_h-zh, minimap.w+xwid, zh);
24714 real_minimap_zoomed.set(minimap_zoomed.x+3, minimap_zoomed.y+5, real_minimap.w, real_minimap.h, real_minimap.xscale*upscale_mm, real_minimap.yscale*upscale_mm);
24715 real_minimap_zoomed.fw = real_minimap_zoomed.xscale*8;
24716 real_minimap_zoomed.fh = real_minimap_zoomed.yscale*8;
24717
24718 screrrorpos.x = 575;
24719 screrrorpos.y = 388;
24720
24721 mouse_scroll_h=10;
24722
24723 favorites_list.x=favorites_window.x+8;
24724 favorites_list.y=favorites_window.y+16;
24725 favorites_list.xscale = 16;
24726 favorites_list.yscale = 16;
24727 favorites_list.w=(favorites_window.w-16)/favorites_list.xscale;
24728 favorites_list.h=(favorites_window.h-24)/favorites_list.yscale;
24729
24730 int bh = 16;
24731 int by = commands_window.y+4;
24732 commands_list.y=by+bh;
24733 commands_list.h=(zq_screen_h - commands_list.y) / commands_list.yscale;
24734 commands_list.x=commands_window.x+8;
24735
24736 commands_x.w = 20;
24737 commands_x.h = bh;
24738 commands_x.x = commands_list.x + commands_list.tw() - commands_x.w;
24739 commands_x.y = by;
24740
24741 commands_infobtn.w = 20;
24742 commands_infobtn.h = bh;
24743 commands_infobtn.x = commands_x.x - commands_infobtn.w;
24744 commands_infobtn.y = by;
24745
24746 commands_zoombtn.w = 20;
24747 commands_zoombtn.h = bh;
24748 commands_zoombtn.x = commands_infobtn.x - commands_zoombtn.w;
24749 commands_zoombtn.y = by;
24750
24751 commands_txt.x = commands_list.x;
24752 commands_txt.y = by+(bh-text_height(get_zc_font(font_lfont_l)))/2;
24753
24754 favorites_x.x = favorites_window.x + favorites_window.w - favorites_x.w - 2;
24755 favorites_x.y = favorites_list.y-15;
24756
24757 favorites_infobtn.x = favorites_x.x - favorites_infobtn.w;
24758 favorites_infobtn.y = favorites_x.y;
24759
24760 favorites_zoombtn.x = favorites_infobtn.x - favorites_zoombtn.w;
24761 favorites_zoombtn.y = favorites_infobtn.y;
24762
24763 favorites_pgright.x = favorites_zoombtn.x - favorites_pgright.w;
24764 favorites_pgright.y = favorites_zoombtn.y;
24765
24766 favorites_pgleft.x = favorites_pgright.x - favorites_pgleft.w;
24767 favorites_pgleft.y = favorites_pgleft.y;
24768
24769 txtoffs_single.x = 22;
24770 txtoffs_single.y = 6;
24771 txtoffs_double_1.x = 22;
24772 txtoffs_double_1.y = 2;
24773 txtoffs_double_2.x = 22;
24774 txtoffs_double_2.y = 10;
24775 panel_align = 0;
24776
24777 int sqx = minimap.x+minimap.tw();
24778 squares_panel.set(sqx,main_panel.y,main_panel.tw()-sqx,main_panel.th());
24779 int x2 = sqx+4;
24780 int x1 = x2 - (20+(8*3)+2);
24781 int y1 = main_panel.y+10;
24782 int sw = 20, sh = 20;
24783 int offs = sh+4;
24784
24785 itemsqr_pos.set(x2,y1+(0*offs),sw,sh);
24786 flagsqr_pos.set(x2,y1+(1*offs),sw,sh);
24787 stairsqr_pos.set(x2,y1+(2*offs),sw,sh);
24788 warparrival_pos.set(x2,y1+(6*offs),sw,sh);
24789
24790 enemy_prev_pos.x = main_panel.x+14;
24791 enemy_prev_pos.y = main_panel.y+12 + minimap.h;
24792 enemy_prev_pos.w = 4;
24793 enemy_prev_pos.h = 3;
24794 enemy_prev_pos.xscale = 16;
24795 enemy_prev_pos.yscale = 16;
24796 enemy_prev_pos.fw = enemy_prev_pos.xscale*2;
24797 enemy_prev_pos.fh = enemy_prev_pos.yscale*2;
24798
24799 warpret_pos[0].set(x1,y1+(4*offs),sw,sh);
24800 warpret_pos[1].set(x1,y1+(5*offs),sw,sh);
24801 warpret_pos[2].set(x2,y1+(4*offs),sw,sh);
24802 warpret_pos[3].set(x2,y1+(5*offs),sw,sh);
24803
24804 auto& last_alias_list = comboaliaslist[num_combo_cols-1];
24805 combopool_preview.x=comboaliaslist[0].x;
24806 combopool_preview.y=last_alias_list.y+(last_alias_list.h*last_alias_list.yscale)+16;
24807 combopool_preview.w=(last_alias_list.x+(last_alias_list.w*last_alias_list.xscale))-comboaliaslist[0].x;
24808 combopool_preview.h=(favorites_window.y-combopool_preview.y);//+favorites_window.h-10;
24809 combopool_preview.w -= combopool_preview.w%16;
24810 combopool_preview.h -= combopool_preview.h%16;
24811
24812 FONT* tfont = get_zc_font(font_lfont_l);
24813 combopool_prevbtn.w = text_length(tfont, "Unweighted")+10;
24814 combopool_prevbtn.h = 11;
24815 combopool_prevbtn.x = combopool_preview.x;
24816 combopool_prevbtn.y = combopool_preview.y-combopool_prevbtn.h;
24817
24818 mappage_count = 9;
24819
24820 txfont = get_zc_font(font_lfont_l);
24821 combo_preview_text1.set(combo_preview.x-9,combo_preview.y,1,3,1,text_height(txfont));
24822 combo_preview_text2.set(combo_preview2.x+combo_preview2.w+8,combo_preview2.y,1,3,1,text_height(txfont));
24823
24824 favorites_x.w = 30;
24825 favorites_infobtn.w = 30;
24826 favorites_zoombtn.w = 30;
24827 favorites_pgleft.w = 30;
24828 favorites_pgright.w = 30;
24829 }
24830 //Same in all modes
24831 {
24832
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
8 if(is_compact ? compact_zoomed_cmd : large_zoomed_cmd)
24833 {
24834 8 commands_list.w /= 2;
24835 8 commands_list.xscale *= 2;
24836 8 }
24837
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
8 if(is_compact ? compact_zoomed_fav : large_zoomed_fav)
24838 {
24839
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(favorites_list.w%2)
24840 favorites_list.x += (favorites_list.xscale / 2);
24841 8 favorites_list.xscale *= 2;
24842 8 favorites_list.yscale *= 2;
24843 8 favorites_list.w /= 2;
24844 8 favorites_list.h /= 2;
24845 8 }
24846
24847 8 favorites_x.h = 14;
24848 8 favorites_x.x = favorites_window.x + favorites_window.w - favorites_x.w - 2;
24849 8 favorites_x.y = favorites_list.y-15;
24850
24851 8 favorites_infobtn.h = favorites_x.h;
24852 8 favorites_infobtn.x = favorites_x.x - favorites_infobtn.w;
24853 8 favorites_infobtn.y = favorites_x.y;
24854
24855 8 favorites_zoombtn.h = favorites_infobtn.h;
24856 8 favorites_zoombtn.x = favorites_infobtn.x - favorites_zoombtn.w;
24857 8 favorites_zoombtn.y = favorites_infobtn.y;
24858
24859 8 favorites_pgright.h = favorites_zoombtn.h;
24860 8 favorites_pgright.x = favorites_zoombtn.x - favorites_pgright.w;
24861 8 favorites_pgright.y = favorites_zoombtn.y;
24862
24863 8 favorites_pgleft.h = favorites_pgright.h;
24864 8 favorites_pgleft.x = favorites_pgright.x - favorites_pgleft.w;
24865 8 favorites_pgleft.y = favorites_pgright.y;
24866
24867 8 mainbar.x = dialogs[0].x+dialogs[0].w;
24868 8 mainbar.y = 0;
24869 8 mainbar.w = zoomoutbtn.x-mainbar.x;
24870 8 mainbar.h = drawmode_btn.h;
24871 }
24872
24873 //Ensure current combo list selected is valid
24874 8 current_combolist=vbound(current_combolist,0,num_combo_cols-1);
24875 8 current_comboalist=vbound(current_comboalist,0,num_combo_cols-1);
24876 8 current_cpoollist=vbound(current_cpoollist,0,num_combo_cols-1);
24877 8 current_cautolist = vbound(current_cautolist, 0, num_combo_cols - 1);
24878
24879 //Generate bitmaps
24880 8 init_bitmap(&mapscreenbmp,16*(showedges?18:16),16*(showedges?13:11));
24881 8 init_bitmap(&brushbmp,256*mapscreen_screenunit_scale,176*mapscreen_screenunit_scale);
24882 8 init_bitmap(&brushscreen,(256+(showedges?16:0))*mapscreen_screenunit_scale,(176+(showedges?16:0))*mapscreen_screenunit_scale);
24883
24884 8 init_bitmap(&screen2,zq_screen_w,zq_screen_h);
24885 8 init_bitmap(&tmp_scr,zq_screen_w,zq_screen_h);
24886 8 init_bitmap(&menu1,zq_screen_w,zq_screen_h);
24887 8 init_bitmap(&menu3,zq_screen_w,zq_screen_h);
24888
24889 8 center_zq_class_dialogs();
24890 8 center_zq_files_dialogs();
24891 8 center_zq_subscreen_dialogs();
24892 8 center_zq_tiles_dialogs();
24893 8 center_zquest_dialogs();
24894
24895 8 aspect_ratio = zq_screen_h / double(zq_screen_w);
24896
24897 8 mmap_init();
24898 8 }
24899
24900 11 void remove_locked_params_on_exit()
24901 {
24902 11 al_trace("Removing timers. \n");
24903 11 remove_int(fps_callback);
24904 11 remove_int(dclick_check);
24905 11 }
24906
24907 11 void destroy_bitmaps_on_exit()
24908 {
24909 11 al_trace("Cleaning bitmaps...");
24910 11 destroy_bitmap(screen2);
24911 11 destroy_bitmap(tmp_scr);
24912 11 destroy_bitmap(menu1);
24913 11 destroy_bitmap(menu3);
24914 11 destroy_bitmap(mapscreenbmp);
24915 11 destroy_bitmap(dmapbmp_small);
24916 11 destroy_bitmap(dmapbmp_large);
24917 11 destroy_bitmap(brushbmp);
24918 11 destroy_bitmap(brushscreen);
24919 11 al_trace("...");
24920
24921
2/2
✓ Branch 0 taken 528 times.
✓ Branch 1 taken 11 times.
539 for(int32_t i=0; i<MOUSE_BMP_MAX*4; i++)
24922 {
24923 528 destroy_bitmap(mouse_bmp[i/4][i%4]);
24924 528 destroy_bitmap(mouse_bmp_1x[i/4][i%4]);
24925 528 }
24926
24927
2/2
✓ Branch 0 taken 352 times.
✓ Branch 1 taken 11 times.
363 for(int32_t i=0; i<ICON_BMP_MAX*4; i++)
24928 352 destroy_bitmap(icon_bmp[i/4][i%4]);
24929
24930
2/2
✓ Branch 0 taken 704 times.
✓ Branch 1 taken 11 times.
715 for(int32_t i=0; i<16*4; i++)
24931 704 destroy_bitmap(flag_bmp[i/4][i%4]);
24932
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 11 times.
33 for(int32_t i=0; i<2; i++)
24933 22 destroy_bitmap(select_bmp[i]);
24934
24935
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 11 times.
99 for(int32_t i=0; i<MAXARROWS; i++)
24936 88 destroy_bitmap(arrow_bmp[i]);
24937
24938 11 al_trace(" OK. \n");
24939 11 }
24940
24941
24942 11 void quit_game()
24943 {
24944 11 set_last_timed_save(nullptr);
24945 11 save_config_file();
24946 11 zc_set_palette(black_palette);
24947 11 zc_stop_midi();
24948
24949 11 remove_locked_params_on_exit();
24950
24951 11 al_trace("Cleaning sfx. \n");
24952
24953
2/2
✓ Branch 0 taken 2816 times.
✓ Branch 1 taken 11 times.
2827 for(int32_t i=0; i<WAV_COUNT; i++)
24954 {
24955
2/2
✓ Branch 0 taken 2805 times.
✓ Branch 1 taken 11 times.
2816 if(customsfxdata[i].data!=NULL)
24956 {
24957 // delete [] customsfxdata[i].data;
24958 2805 free(customsfxdata[i].data);
24959 2805 }
24960
24961
1/2
✓ Branch 0 taken 2816 times.
✗ Branch 1 not taken.
2816 delete [] sfx_string[i];
24962 2816 }
24963
24964
2/2
✓ Branch 0 taken 2816 times.
✓ Branch 1 taken 11 times.
2827 for(int32_t i=0; i<MAXWPNS; i++)
24965 {
24966
1/2
✓ Branch 0 taken 2816 times.
✗ Branch 1 not taken.
2816 delete [] weapon_string[i];
24967 2816 }
24968
24969
2/2
✓ Branch 0 taken 2816 times.
✓ Branch 1 taken 11 times.
2827 for(int32_t i=0; i<MAXITEMS; i++)
24970 {
24971
1/2
✓ Branch 0 taken 2816 times.
✗ Branch 1 not taken.
2816 delete [] item_string[i];
24972 2816 }
24973
24974
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 11 times.
5643 for(int32_t i=0; i<eMAXGUYS; i++)
24975 {
24976
1/2
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
5632 delete [] guy_string[i];
24977 5632 }
24978
24979 11 al_trace("Cleaning script buffer. \n");
24980
24981
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 11 times.
5643 for(int32_t i=0; i<NUMSCRIPTFFC; i++)
24982 {
24983
2/4
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5632 times.
5632 if(ffscripts[i]!=NULL) delete ffscripts[i];
24984 5632 }
24985
24986
2/2
✓ Branch 0 taken 2816 times.
✓ Branch 1 taken 11 times.
2827 for(int32_t i=0; i<NUMSCRIPTITEM; i++)
24987 {
24988
2/4
✓ Branch 0 taken 2816 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2816 times.
2816 if(itemscripts[i]!=NULL) delete itemscripts[i];
24989 2816 }
24990
24991
2/2
✓ Branch 0 taken 2816 times.
✓ Branch 1 taken 11 times.
2827 for(int32_t i=0; i<NUMSCRIPTGUYS; i++)
24992 {
24993
2/4
✓ Branch 0 taken 2816 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2816 times.
2816 if(guyscripts[i]!=NULL) delete guyscripts[i];
24994 2816 }
24995
24996
2/2
✓ Branch 0 taken 2816 times.
✓ Branch 1 taken 11 times.
2827 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
24997 {
24998
2/4
✓ Branch 0 taken 2816 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2816 times.
2816 if(lwpnscripts[i]!=NULL) delete lwpnscripts[i];
24999 2816 }
25000
25001
2/2
✓ Branch 0 taken 2816 times.
✓ Branch 1 taken 11 times.
2827 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
25002 {
25003
2/4
✓ Branch 0 taken 2816 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2816 times.
2816 if(ewpnscripts[i]!=NULL) delete ewpnscripts[i];
25004 2816 }
25005
25006
2/2
✓ Branch 0 taken 2816 times.
✓ Branch 1 taken 11 times.
2827 for(int32_t i=0; i<NUMSCRIPTSCREEN; i++)
25007 {
25008
2/4
✓ Branch 0 taken 2816 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2816 times.
2816 if(screenscripts[i]!=NULL) delete screenscripts[i];
25009 2816 }
25010
25011
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 11 times.
44 for(int32_t i=0; i<3; i++) //should this be NUMSCRIPTGLOBAL or NUMSCRIPTGLOBALOLD? -Z
25012 {
25013
2/4
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 33 times.
33 if(globalscripts[i]!=NULL) delete globalscripts[i];
25014 33 }
25015
25016
2/2
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 11 times.
66 for(int32_t i=0; i<NUMSCRIPTHERO; i++)
25017 {
25018
2/4
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 55 times.
55 if(playerscripts[i]!=NULL) delete playerscripts[i];
25019 55 }
25020
25021
2/2
✓ Branch 0 taken 2816 times.
✓ Branch 1 taken 11 times.
2827 for(int32_t i=0; i<NUMSCRIPTSDMAP; i++)
25022 {
25023
2/4
✓ Branch 0 taken 2816 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2816 times.
2816 if(dmapscripts[i]!=NULL) delete dmapscripts[i];
25024 2816 }
25025
2/2
✓ Branch 0 taken 2816 times.
✓ Branch 1 taken 11 times.
2827 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE; i++)
25026 {
25027
2/4
✓ Branch 0 taken 2816 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2816 times.
2816 if(itemspritescripts[i]!=NULL) delete itemspritescripts[i];
25028 2816 }
25029
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 11 times.
5643 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA; i++)
25030 {
25031
2/4
✓ Branch 0 taken 5632 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5632 times.
5632 if(comboscripts[i]!=NULL) delete comboscripts[i];
25032 5632 }
25033
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 2816 times.
2827 for(int32_t i=0; i<NUMSCRIPTSSUBSCREEN; i++)
25034 {
25035
2/4
✓ Branch 0 taken 2816 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2816 times.
2816 if(subscreenscripts[i]!=NULL) delete subscreenscripts[i];
25036 2816 }
25037
25038 11 al_trace("Cleaning qst buffers. \n");
25039 11 del_qst_buffers();
25040
25041
25042 11 al_trace("Cleaning midis. \n");
25043
25044
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(customtunes)
25045 {
25046
2/2
✓ Branch 0 taken 2816 times.
✓ Branch 1 taken 11 times.
2827 for(int32_t i=0; i<MAXCUSTOMMIDIS_ZQ; i++)
25047 2816 customtunes[i].reset();
25048
25049 11 free(customtunes);
25050 11 }
25051
25052 11 al_trace("Cleaning undotilebuf. \n");
25053
25054 11 undocombobuf.clear();
25055
25056
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 3 times.
11 if(newundotilebuf)
25057 {
25058
2/2
✓ Branch 0 taken 1716000 times.
✓ Branch 1 taken 8 times.
1716008 for(int32_t i=0; i<NEWMAXTILES; i++)
25059
1/2
✓ Branch 0 taken 1716000 times.
✗ Branch 1 not taken.
1716000 if(newundotilebuf[i].data) free(newundotilebuf[i].data);
25060
25061 8 free(newundotilebuf);
25062 8 }
25063
25064
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(filepath) free(filepath);
25065
25066
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(datapath) free(datapath);
25067
25068
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(midipath) free(midipath);
25069
25070
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(imagepath) free(imagepath);
25071
25072
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(tmusicpath) free(tmusicpath);
25073
25074
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(last_timed_save) free(last_timed_save);
25075
25076 11 destroy_bitmaps_on_exit();
25077 11 }
25078
25079 void quit_game2()
25080 {
25081 set_last_timed_save(nullptr);
25082 save_config_file();
25083 zc_set_palette(black_palette);
25084 zc_stop_midi();
25085
25086 remove_locked_params_on_exit();
25087
25088 al_trace("Cleaning sfx. \n");
25089
25090 for(int32_t i=0; i<WAV_COUNT; i++)
25091 {
25092 if(customsfxdata[i].data!=NULL)
25093 {
25094 // delete [] customsfxdata[i].data;
25095 free(customsfxdata[i].data);
25096 }
25097
25098 delete [] sfx_string[i];
25099 }
25100
25101 for(int32_t i=0; i<MAXWPNS; i++)
25102 {
25103 delete [] weapon_string[i];
25104 }
25105
25106 for(int32_t i=0; i<MAXITEMS; i++)
25107 {
25108 delete [] item_string[i];
25109 }
25110
25111 for(int32_t i=0; i<eMAXGUYS; i++)
25112 {
25113 delete [] guy_string[i];
25114 }
25115
25116 al_trace("Cleaning script buffer. \n");
25117
25118 for(int32_t i=0; i<NUMSCRIPTFFC; i++)
25119 {
25120 if(ffscripts[i]!=NULL) delete ffscripts[i];
25121 }
25122
25123 for(int32_t i=0; i<NUMSCRIPTITEM; i++)
25124 {
25125 if(itemscripts[i]!=NULL) delete itemscripts[i];
25126 }
25127
25128 for(int32_t i=0; i<NUMSCRIPTGUYS; i++)
25129 {
25130 if(guyscripts[i]!=NULL) delete guyscripts[i];
25131 }
25132
25133 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
25134 {
25135 if(lwpnscripts[i]!=NULL) delete lwpnscripts[i];
25136 }
25137
25138 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
25139 {
25140 if(ewpnscripts[i]!=NULL) delete ewpnscripts[i];
25141 }
25142
25143 for(int32_t i=0; i<NUMSCRIPTSCREEN; i++)
25144 {
25145 if(screenscripts[i]!=NULL) delete screenscripts[i];
25146 }
25147
25148 for(int32_t i=0; i<3; i++) //should this be NUMSCRIPTGLOBAL or NUMSCRIPTGLOBALOLD? -Z
25149 {
25150 if(globalscripts[i]!=NULL) delete globalscripts[i];
25151 }
25152
25153 for(int32_t i=0; i<NUMSCRIPTHERO; i++)
25154 {
25155 if(playerscripts[i]!=NULL) delete playerscripts[i];
25156 }
25157
25158 for(int32_t i=0; i<NUMSCRIPTSDMAP; i++)
25159 {
25160 if(dmapscripts[i]!=NULL) delete dmapscripts[i];
25161 }
25162 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE; i++)
25163 {
25164 if(itemspritescripts[i]!=NULL) delete itemspritescripts[i];
25165 }
25166 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA; i++)
25167 {
25168 if(comboscripts[i]!=NULL) delete comboscripts[i];
25169 }
25170 for(int32_t i=0; i<NUMSCRIPTSSUBSCREEN; i++)
25171 {
25172 if(subscreenscripts[i]!=NULL) delete subscreenscripts[i];
25173 }
25174
25175 al_trace("Cleaning qst buffers. \n");
25176 del_qst_buffers();
25177
25178
25179 al_trace("Cleaning midis. \n");
25180
25181 if(customtunes)
25182 {
25183 for(int32_t i=0; i<MAXCUSTOMMIDIS_ZQ; i++)
25184 customtunes[i].reset();
25185
25186 free(customtunes);
25187 }
25188
25189 al_trace("Cleaning undotilebuf. \n");
25190
25191 undocombobuf.clear();
25192
25193 if(newundotilebuf)
25194 {
25195 for(int32_t i=0; i<NEWMAXTILES; i++)
25196 if(newundotilebuf[i].data) free(newundotilebuf[i].data);
25197
25198 free(newundotilebuf);
25199 }
25200
25201 if(filepath) free(filepath);
25202
25203 if(datapath) free(datapath);
25204
25205 if(midipath) free(midipath);
25206
25207 if(imagepath) free(imagepath);
25208
25209 if(tmusicpath) free(tmusicpath);
25210
25211 if(last_timed_save) free(last_timed_save);
25212 }
25213
25214 8 void center_zquest_dialogs()
25215 {
25216 8 jwin_center_dialog(assignscript_dlg);
25217 8 jwin_center_dialog(autolayer_dlg);
25218 8 center_zq_cset_dialogs();
25219 8 jwin_center_dialog(change_track_dlg);
25220 8 jwin_center_dialog(csetfix_dlg);
25221 8 jwin_center_dialog(dmapmaps_dlg);
25222 8 center_zq_door_dialogs();
25223 8 jwin_center_dialog(editcomboa_dlg);
25224 8 jwin_center_dialog(editinfo_dlg);
25225 8 jwin_center_dialog(editmusic_dlg);
25226 8 jwin_center_dialog(editshop_dlg);
25227 8 jwin_center_dialog(ffcombo_sel_dlg);
25228 8 jwin_center_dialog(getnum_dlg);
25229 8 jwin_center_dialog(layerdata_dlg);
25230 8 jwin_center_dialog(list_dlg);
25231 8 jwin_center_dialog(loadmap_dlg);
25232 8 jwin_center_dialog(misccolors_dlg);
25233 8 jwin_center_dialog(newcomboa_dlg);
25234 8 jwin_center_dialog(orgcomboa_dlg);
25235 8 jwin_center_dialog(path_dlg);
25236 8 jwin_center_dialog(screen_pal_dlg);
25237 8 jwin_center_dialog(secret_dlg);
25238 8 jwin_center_dialog(selectmusic_dlg);
25239 8 jwin_center_dialog(showpal_dlg);
25240 8 jwin_center_dialog(strlist_dlg);
25241 8 jwin_center_dialog(template_dlg);
25242 8 jwin_center_dialog(tp_dlg);
25243 8 jwin_center_dialog(under_dlg);
25244 8 jwin_center_dialog(tilewarp_dlg);
25245 8 jwin_center_dialog(sidewarp_dlg);
25246 8 jwin_center_dialog(warpring_dlg);
25247 8 center_zscript_dialogs();
25248 8 }
25249
25250
25251 void animate_coords()
25252 {
25253 coord_frame=(coord_timer>>3)&3;
25254
25255 if(++coord_timer>=(1<<5))
25256 {
25257 coord_timer=0;
25258 }
25259 }
25260
25261 static const char *help_list[] =
25262 {
25263 "PREVIEW MODE",
25264 "PgUp/PgDn - Scroll through hotkey list",
25265 "Esc/Enter - Exit Preview Mode",
25266 "R - Restore screen to original state",
25267 "C - Toggle combo cycling On/Off",
25268 "S - Trigger screen secrets",
25269 "Q/W/F - These still work",
25270 "P - Pause everything",
25271 "A - Advance frame-by-frame",
25272 "1-4 - Trigger tile warp A-D",
25273 "5-8 - Trigger side warp A-D",
25274 "9 - Enable timed warps",
25275 "",
25276 "",
25277 };
25278
25279 void do_previewtext()
25280 {
25281 FONT* oldfont = font;
25282 font = get_zc_font(font_lfont_l);
25283
25284 //Put in help areas
25285 auto& sqr = preview_text;
25286 int ind = 0, len = 0;
25287 for(int q = 0; q < 12; ++q)
25288 {
25289 int l = text_length(font, help_list[q]);
25290 if(len < l) len = l;
25291 }
25292 sqr.xscale = len+2;
25293 sqr.yscale = text_height(font);
25294 for(int col = 0; col < sqr.w; ++col)
25295 {
25296 for(int row = 0; row < sqr.h; ++row)
25297 {
25298 auto& line = sqr.subsquare(col,row);
25299 textprintf_ex(menu1,font,line.x,line.y,jwin_pal[jcTEXTFG],-1,"%s",help_list[ind++]);
25300 }
25301 }
25302
25303 font = oldfont;
25304 }
25305
25306
25307 bool reload_fonts = false;
25308 void run_zq_frame()
25309 {
25310 if(reload_fonts)
25311 {
25312 init_custom_fonts();
25313 load_size_poses();
25314 reload_fonts = false;
25315 }
25316
25317 domouse();
25318 custom_vsync();
25319 refresh(rCLEAR|rALL);
25320 }
25321 8 int32_t d_nbmenu_proc(int32_t msg,DIALOG *d,int32_t c)
25322 {
25323
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
8 switch(msg)
25324 {
25325 case MSG_VSYNC:
25326 run_zq_frame();
25327 break;
25328 case MSG_GOTMOUSE:
25329 case MSG_XCHAR:
25330 ComboBrushPause=1;
25331 refresh(rMAP);
25332 ComboBrushPause=0;
25333 clear_tooltip();
25334 break;
25335 }
25336
25337 8 return GuiMenu::proc(msg,d,c);
25338 }
25339
25340 bool prv_press=false;
25341
25342 void dopreview()
25343 {
25344 refresh(rMAP);
25345
25346 while(!(gui_mouse_b()))
25347 {
25348 if(keypressed())
25349 {
25350 if(!prv_press)
25351 {
25352 prv_press=true;
25353
25354 switch(readkey()>>8)
25355 {
25356 case KEY_ESC:
25357 case KEY_ENTER:
25358 case KEY_ENTER_PAD:
25359 goto finished;
25360 break;
25361
25362 case KEY_F:
25363 Flags^=cFLAGS;
25364 refresh(rMAP);
25365 break;
25366
25367 case KEY_R:
25368 onReloadPreview();
25369 break;
25370
25371 case KEY_S:
25372 onSecretsPreview();
25373 break;
25374
25375 case KEY_C:
25376 onCopy();
25377 break;
25378
25379 case KEY_A:
25380 onAKey();
25381 break;
25382
25383 case KEY_P:
25384 onP();
25385 break;
25386
25387 case KEY_L:
25388 onShowDarkness();
25389 break;
25390
25391 case KEY_1:
25392 Map.prv_dowarp(0,0);
25393 prv_warp=0;
25394 break;
25395
25396 case KEY_2:
25397 Map.prv_dowarp(0,1);
25398 prv_warp=0;
25399 break;
25400
25401 case KEY_3:
25402 Map.prv_dowarp(0,2);
25403 prv_warp=0;
25404 break;
25405
25406 case KEY_4:
25407 Map.prv_dowarp(0,3);
25408 prv_warp=0;
25409 break;
25410
25411 case KEY_5:
25412 Map.prv_dowarp(1,0);
25413 prv_warp=0;
25414 break;
25415
25416 case KEY_6:
25417 Map.prv_dowarp(1,1);
25418 prv_warp=0;
25419 break;
25420
25421 case KEY_7:
25422 Map.prv_dowarp(1,2);
25423 prv_warp=0;
25424 break;
25425
25426 case KEY_8:
25427 Map.prv_dowarp(1,3);
25428 prv_warp=0;
25429 break;
25430
25431 case KEY_9:
25432 if(prv_twon)
25433 {
25434 prv_twon=0;
25435 Map.set_prvtime(0);
25436 prv_warp=0;
25437 }
25438 else
25439 {
25440 Map.set_prvtime(Map.get_prvscr()->timedwarptics);
25441 prv_twon=1;
25442 }
25443
25444 break;
25445
25446 case KEY_W:
25447 onShowWalkability();
25448 break;
25449
25450 case KEY_Q:
25451 onShowComboInfoCSet();
25452 break;
25453 }
25454 }
25455 else
25456 {
25457 readkey();
25458 }
25459 }
25460 else
25461 {
25462 prv_press=false;
25463 }
25464
25465 if(prv_warp)
25466 {
25467 Map.prv_dowarp(1,0);
25468 prv_warp=0;
25469 }
25470
25471 if(Map.get_prvfreeze())
25472 {
25473 if(Map.get_prvadvance())
25474 {
25475 custom_vsync();
25476 Map.set_prvadvance(0);
25477 }
25478 }
25479 else
25480 {
25481 custom_vsync();
25482 Map.set_prvadvance(0);
25483 }
25484
25485 refresh(rALL);
25486 }
25487
25488 finished:
25489 //Flags=of;
25490 reset_combo_animations();
25491 reset_combo_animations2();
25492 MouseSprite::set(ZQM_NORMAL);
25493 prv_mode=0;
25494 prv_warp=0;
25495 Map.end_prv();
25496 loadlvlpal(Map.getcolor());
25497 rebuild_trans_table();
25498 refresh(rMAP+rMENU);
25499
25500 while(gui_mouse_b())
25501 {
25502 /* do nothing */
25503 rest(1);
25504 }
25505 }
25506
25507 void call_vidmode_dlg();
25508 int32_t onZQVidMode()
25509 {
25510 call_vidmode_dlg();
25511 return D_O_K;
25512 }
25513
25514 bool screenIsScrolling()
25515 {
25516 return false;
25517 }
25518
25519 void write_includepaths()
25520 {
25521 FILE* f = fopen("includepaths.txt", "w");
25522 if(f)
25523 {
25524 fwrite(FFCore.includePathString,1,strlen(FFCore.includePathString),f);
25525 fclose(f);
25526 }
25527 }
25528
25529 11 int32_t save_config_file()
25530 {
25531
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if (!application_has_loaded) return 0;
25532
25533 char qtnametitle[20];
25534 char qtpathtitle[20];
25535 char *datapath2=(char *)malloc(2048);
25536 char *midipath2=(char *)malloc(2048);
25537 char *imagepath2=(char *)malloc(2048);
25538 char *tmusicpath2=(char *)malloc(2048);
25539 strcpy(datapath2, datapath);
25540 strcpy(midipath2, midipath);
25541 strcpy(imagepath2, imagepath);
25542 strcpy(tmusicpath2, tmusicpath);
25543 chop_path(datapath2);
25544 chop_path(midipath2);
25545 chop_path(imagepath2);
25546 chop_path(tmusicpath2);
25547 write_includepaths();
25548
25549 zc_set_config("zquest",data_path_name,datapath2);
25550 zc_set_config("zquest",midi_path_name,midipath2);
25551 zc_set_config("zquest",image_path_name,imagepath2);
25552 zc_set_config("zquest",tmusic_path_name,tmusicpath2);
25553
25554 if (all_get_display() && !all_get_fullscreen_flag() && SaveDragResize)
25555 {
25556 window_width = al_get_display_width(all_get_display());
25557 window_height = al_get_display_height(all_get_display());
25558 zc_set_config("zquest","window_width",window_width);
25559 zc_set_config("zquest","window_height",window_height);
25560 }
25561 if (all_get_display() && !all_get_fullscreen_flag() && SaveWinPos)
25562 {
25563 int o_window_x, o_window_y;
25564 al_get_window_position(all_get_display(), &o_window_x, &o_window_y);
25565 zc_set_config("zquest", "window_x", o_window_x);
25566 zc_set_config("zquest", "window_y", o_window_y);
25567 }
25568
25569 byte b = 0;
25570 for(int32_t x=0; x<7; x++)
25571 {
25572 set_bit(&b,x,LayerMaskInt[x]);
25573 }
25574
25575 zc_set_config("zquest","layer_mask",b);
25576
25577 flush_config_file();
25578 #ifdef __EMSCRIPTEN__
25579 em_sync_fs();
25580 #endif
25581 free(datapath2);
25582 free(midipath2);
25583 free(imagepath2);
25584 free(tmusicpath2);
25585 return 0;
25586 11 }
25587
25588 int32_t d_timer_proc(int32_t msg, DIALOG *d, int32_t c)
25589 {
25590 //these are here to bypass compiler warnings about unused arguments
25591 c=c;
25592 d=d;
25593
25594 switch(msg)
25595 {
25596 case MSG_IDLE:
25597 #ifdef _WIN32
25598 if(zqUseWin32Proc != FALSE)
25599 win32data.Update(Frameskip); //experimental win32 fixes
25600
25601 #endif
25602
25603 // This has been crashing on Windows, and it saves plenty without it
25604 //check_autosave();
25605 break;
25606 }
25607
25608 return D_O_K;
25609 }
25610
25611 void check_autosave()
25612 {
25613 if (!first_save)
25614 return;
25615
25616 if(AutoSaveInterval>0)
25617 {
25618 time(&auto_save_time_current);
25619 auto_save_time_diff = difftime(auto_save_time_current,auto_save_time_start);
25620
25621 if(auto_save_time_diff>AutoSaveInterval*60)
25622 {
25623 MouseSprite::set(ZQM_NORMAL);
25624 replace_extension(last_timed_save, filepath, "qt0", 2047);
25625 set_last_timed_save(last_timed_save);
25626 go();
25627
25628 if((header.zelda_version != ZELDA_VERSION || header.build != VERSION_BUILD))
25629 {
25630 jwin_alert("Auto Save","This quest was saved in an older version of ZQuest.","If you wish to use the autosave feature, you must manually","save the files in this version first.","OK",NULL,13,27,get_zc_font(font_lfont));
25631 time(&auto_save_time_start);
25632 comeback();
25633 return;
25634 }
25635
25636 int32_t ret = save_quest(last_timed_save, true);
25637
25638 if(ret)
25639 {
25640 jwin_alert("Error","Timed save did not complete successfully.",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
25641 set_last_timed_save(nullptr);
25642 }
25643
25644 save_config_file();
25645 time(&auto_save_time_start);
25646 comeback();
25647 }
25648 }
25649 }
25650
25651 void flushItemCache(bool) {}
25652 void ringcolor(bool forceDefault)
25653 {
25654 forceDefault=forceDefault;
25655 }
25656
25657 bool item_disabled(int32_t)
25658 {
25659 return false;
25660 }
25661
25662 int32_t onCmdExit()
25663 {
25664 // replaces onExit for the -large button command "Exit"
25665 close_button_quit = true;
25666 return 0;
25667 }
25668
25669 int32_t onQuickCompile()
25670 {
25671 if(do_compile_and_slots(1,false))
25672 {
25673 saved = false;
25674 InfoDialog("Quick Compile","Success!").show();
25675 }
25676 else
25677 {
25678 InfoDialog("Quick Compile","Failure!").show();
25679 }
25680 return 0;
25681 }
25682 int32_t onSmartCompile()
25683 {
25684 if(do_compile_and_slots(2,false))
25685 {
25686 saved = false;
25687 InfoDialog("Smart Compile","Success!").show();
25688 }
25689 else
25690 {
25691 InfoDialog("Smart Compile","Failure!").show();
25692 }
25693 return 0;
25694 }
25695
25696 int32_t strchrnum(char const* str, char c)
25697 {
25698 for(int32_t i=0; str[i]; ++i)
25699 {
25700 if(str[i]==c)
25701 {
25702 return i;
25703 }
25704 }
25705
25706 return -1;
25707 }
25708
25709 int32_t get_longest_line_length(FONT *f, char* str)
25710 {
25711 int32_t maxlen=0;
25712 char* tmpstr = str;
25713 char temp=0;
25714 int32_t t=0;
25715 int32_t new_t=-1;
25716 while(tmpstr[0])
25717 {
25718 t=strchrnum(tmpstr, '\n');
25719
25720 if(t==-1)
25721 {
25722 t=(int32_t)strlen(tmpstr);
25723 }
25724
25725 if((uint32_t)t!=strlen(tmpstr))
25726 {
25727 new_t=t+1;
25728 }
25729 else
25730 {
25731 new_t=-1;
25732 }
25733
25734 temp = tmpstr[t];
25735 tmpstr[t]=0;
25736 maxlen=zc_max(maxlen,text_length(f, tmpstr));
25737 tmpstr[t]=temp;
25738
25739 if(new_t!=-1)
25740 {
25741 tmpstr+=new_t;
25742 }
25743 else break;
25744 }
25745 return maxlen;
25746 }
25747
25748 int32_t count_lines(char const* str)
25749 {
25750 int32_t count=1;
25751
25752 for(word i=0; i<strlen(str); ++i)
25753 {
25754 if(str[i]=='\n')
25755 {
25756 ++count;
25757 }
25758 }
25759
25760 return count;
25761 }
25762
25763 void debug_pos(size_and_pos const& pos, int color)
25764 {
25765 if(pos.w < 1 || pos.h < 1)
25766 return;
25767 if(pos.xscale > 1 || pos.yscale > 1)
25768 {
25769 auto maxind = pos.w*pos.h;
25770 for(auto q = 0; q < maxind; ++q)
25771 {
25772 auto& sub = pos.subsquare(q);
25773 if(sub.x < 0) break;
25774 highlight_sqr(screen, color, sub, 1);
25775 }
25776 }
25777 else
25778 {
25779 if(pos.fw > -1 && pos.fh > -1)
25780 highlight_frag(screen, color, pos, 1);
25781 else highlight_sqr(screen, color, pos, 1);
25782 }
25783 }
25784
25785 void textbox_out(BITMAP* dest, FONT* font, int x, int y, int fg, int bg, char const* str, int align, size_and_pos* dims)
25786 {
25787 static size_and_pos nilsz;
25788 size_and_pos& txbox = dims ? *dims : nilsz;
25789
25790 char* kill = (char*)malloc(strlen(str)+1);
25791 char *tmpstr = kill;
25792 strcpy(tmpstr,str);
25793
25794 while(tmpstr[0] == '\n')
25795 ++tmpstr;
25796 int len = strlen(tmpstr);
25797 while(tmpstr[len-1] == '\n')
25798 tmpstr[--len] = 0;
25799
25800 txbox.x=x;
25801 txbox.y=y;
25802 int32_t lines=count_lines(tmpstr);
25803 txbox.w = 1;
25804 txbox.h = lines;
25805 txbox.xscale = get_longest_line_length(font, tmpstr);
25806 txbox.yscale = text_height(font);
25807
25808 int ax = 0; //Aligned x
25809 switch(align)
25810 {
25811 case 0: //left
25812 break;
25813 case 1: //center
25814 txbox.x -= txbox.xscale/2;
25815 ax = txbox.xscale/2;
25816 break;
25817 case 2: //right
25818 txbox.x -= txbox.xscale;
25819 ax = txbox.xscale;
25820 break;
25821 }
25822
25823 int bw = txbox.w*txbox.xscale;
25824 int bh = txbox.h*txbox.yscale;
25825 BITMAP* outbmp = create_bitmap_ex(8, bw, bh);
25826 clear_to_color(outbmp, bg);
25827
25828 char temp = 0;
25829 int32_t t=0;
25830 int32_t new_t=-1;
25831 int32_t line=0;
25832
25833 while(tmpstr[t])
25834 {
25835 t=strchrnum(tmpstr, '\n');
25836
25837 if(t==-1)
25838 t=(int32_t)strlen(tmpstr);
25839
25840 if((uint32_t)t!=strlen(tmpstr))
25841 new_t=t+1;
25842 else
25843 new_t=-1;
25844
25845 temp = tmpstr[t];
25846 tmpstr[t]=0;
25847 gui_textout_ln(outbmp, font, (ucc*)tmpstr, ax, (line*txbox.yscale), fg, -1, align);
25848 tmpstr[t]=temp;
25849 ++line;
25850
25851 if(new_t!=-1)
25852 {
25853 tmpstr+=new_t;
25854 t=0;
25855 }
25856 }
25857
25858 blit(outbmp, dest, 0, 0, txbox.x, txbox.y, bw, bh);
25859 destroy_bitmap(outbmp);
25860 free(kill);
25861 }
25862
25863 void highlight_sqr(BITMAP* dest, int color, int x, int y, int w, int h, int thick)
25864 {
25865 for(int q = 0; q < thick; ++q)
25866 {
25867 safe_rect(dest, x+q, y+q, x+w-1-q, y+h-1-q, color);
25868 }
25869 }
25870 void highlight_sqr(BITMAP* dest, int color, size_and_pos const& rec, int thick)
25871 {
25872 highlight_sqr(dest, color, rec.x, rec.y, rec.tw(), rec.th(), thick);
25873 }
25874 void highlight_frag(BITMAP* dest, int color, int x1, int y1, int w, int h, int fw, int fh, int thick)
25875 {
25876 int xc = x1+fw-1;
25877 int yc = y1+fh-1;
25878 int x2 = x1+w-1;
25879 int y2 = y1+h-1;
25880
25881 hline(dest, x1, y1, x2, color);
25882 vline(dest, x1, y1, y2, color);
25883
25884 hline(dest, x1, y2, xc, color);
25885 vline(dest, x2, y1, yc, color);
25886 hline(dest, xc, yc, x2, color);
25887 vline(dest, xc, yc, y2, color);
25888 }
25889 void highlight_frag(BITMAP* dest, int color, size_and_pos const& rec, int thick)
25890 {
25891 highlight_frag(dest, color, rec.x, rec.y, rec.tw(), rec.th(), rec.fw, rec.fh, thick);
25892 }
25893
25894 void highlight(BITMAP* dest, size_and_pos& hl)
25895 {
25896 if(hl.fw > -1 && hl.fh > -1)
25897 {
25898 highlight_frag(dest, hl.data[1], hl, hl.data[0]);
25899 }
25900 else highlight_sqr(dest, hl.data[1], hl, hl.data[0]);
25901 }
25902
25903 std::pair<int, int> get_box_text_size(char const* tipmsg, double txscale)
25904 {
25905 if(txscale < 1) txscale = 1;
25906 char* kill = (char*)malloc(strlen(tipmsg)+1);
25907 char *tmpstr = kill;
25908 strcpy(tmpstr,tipmsg);
25909
25910 while(tmpstr[0] == '\n')
25911 ++tmpstr;
25912 int len = strlen(tmpstr);
25913 while(tmpstr[len-1] == '\n')
25914 tmpstr[--len] = 0;
25915
25916 int32_t lines = count_lines(tmpstr);
25917 int txlen = get_longest_line_length(font, tmpstr);
25918 int txhei = lines*text_height(font);
25919 int tx_sclen = (txlen * txscale);
25920 int tx_schei = (txhei * txscale);
25921 int w = tx_sclen + 8 + 1;
25922 int h = tx_schei + 8 + 1;
25923 if (w > zq_screen_w)
25924 w = zq_screen_w;
25925 if (h > zq_screen_h)
25926 h = zq_screen_h;
25927 return {w, h};
25928 }
25929
25930 void draw_box(BITMAP* destbmp, size_and_pos* pos, char const* tipmsg, double txscale)
25931 {
25932 if(txscale < 1) txscale = 1;
25933 char* kill = (char*)malloc(strlen(tipmsg)+1);
25934 char *tmpstr = kill;
25935 strcpy(tmpstr,tipmsg);
25936
25937 while(tmpstr[0] == '\n')
25938 ++tmpstr;
25939 int len = strlen(tmpstr);
25940 while(tmpstr[len-1] == '\n')
25941 tmpstr[--len] = 0;
25942
25943 auto& box = *pos;
25944 clear_bitmap(destbmp);
25945
25946 int32_t lines=count_lines(tmpstr);
25947 int txlen = get_longest_line_length(font, tmpstr);
25948 int txhei = lines*text_height(font);
25949 int tx_sclen = (txlen * txscale);
25950 int tx_schei = (txhei * txscale);
25951 box.w = tx_sclen + 8 + 1;
25952 box.h = tx_schei + 8 + 1;
25953 if (box.w > zq_screen_w)
25954 box.w = zq_screen_w;
25955 if (box.h > zq_screen_h)
25956 box.h = zq_screen_h;
25957
25958 if(box.x+box.w>=zq_screen_w)
25959 {
25960 box.x=(zq_screen_w - box.w);
25961 }
25962
25963 if(box.y+box.h>=zq_screen_h)
25964 {
25965 box.y=(zq_screen_h - box.h);
25966 }
25967
25968 rectfill(destbmp, 1, 1, box.w-3, box.h-3, jwin_pal[jcTEXTBG]);
25969 rect(destbmp, 0, 0, box.w-2, box.h-2, jwin_pal[jcTEXTFG]);
25970 vline(destbmp, box.w-1, 0, box.h-1, jwin_pal[jcTEXTFG]);
25971 hline(destbmp, 1, box.h-1, box.w-2, jwin_pal[jcTEXTFG]);
25972 destbmp->line[box.h-1][0]=0;
25973 destbmp->line[0][box.w-1]=0;
25974
25975 char temp = 0;
25976 int32_t t=0;
25977 int32_t new_t=-1;
25978 int32_t line=0;
25979
25980 BITMAP* txbmp = create_bitmap_ex(8,box.w,box.h);
25981 clear_bitmap(txbmp);
25982 while(tmpstr[t])
25983 {
25984 t=strchrnum(tmpstr, '\n');
25985
25986 if(t==-1)
25987 {
25988 t=(int32_t)strlen(tmpstr);
25989 }
25990
25991 if((uint32_t)t!=strlen(tmpstr))
25992 {
25993 new_t=t+1;
25994 }
25995 else
25996 {
25997 new_t=-1;
25998 }
25999
26000 temp = tmpstr[t];
26001 tmpstr[t]=0;
26002 textprintf_ex(txbmp, font, 0, (line*text_height(font)), jwin_pal[jcTEXTFG], -1, "%s", tmpstr);
26003 tmpstr[t]=temp;
26004 ++line;
26005
26006 if(new_t!=-1)
26007 {
26008 tmpstr+=new_t;
26009 t=0;
26010 }
26011 }
26012 masked_stretch_blit(txbmp,destbmp,0,0,txlen,txhei,4,4,tx_sclen,tx_schei);
26013 destroy_bitmap(txbmp);
26014 free(kill);
26015 }
26016
26017 void update_tooltip(int32_t x, int32_t y, size_and_pos const& sqr, char const* tipmsg, double scale)
26018 {
26019 update_tooltip(x,y,sqr.x,sqr.y,sqr.w*sqr.xscale,sqr.h*sqr.yscale,tipmsg,sqr.fw,sqr.fh,scale);
26020 }
26021 void update_tooltip(int32_t x, int32_t y, int32_t tx, int32_t ty, int32_t tw, int32_t th, char const* tipmsg, int fw, int fh, double scale)
26022 {
26023 if(!EnableTooltips)
26024 {
26025 return;
26026 }
26027
26028 ttip_install(ttip_global_id, tipmsg, tx, ty, tw, th, x, y, fw, fh);
26029 }
26030
26031 void ZQ_ClearQuestPath()
26032 {
26033 zc_set_config("zquest","win_last_quest",(char const*)nullptr);
26034 strcpy(filepath,"");
26035 }
26036
26037 //FFCore
26038
26039 void FFScript::init()
26040 {
26041 for ( int32_t q = 0; q < wexLast; q++ ) warpex[q] = 0;
26042 numscriptdraws = 0;
26043 max_ff_rules = qr_MAX;
26044 temp_no_stepforward = 0;
26045 nostepforward = 0;
26046
26047 coreflags = 0;
26048 skip_ending_credits = 0;
26049 music_update_cond = 0;
26050 music_update_flags = 0;
26051 for ( int32_t q = 0; q < susptLAST; q++ ) { system_suspend[q] = false; }
26052
26053 //for ( int32_t q = 0; q < 512; q++ ) FF_rules[q] = 0;
26054 int32_t usr_midi_volume = usr_digi_volume = usr_sfx_volume = usr_music_volume = usr_panstyle = 0;
26055 FF_hero_action = 0;
26056 enemy_removal_point[spriteremovalY1] = -32767;
26057 enemy_removal_point[spriteremovalY2] = 32767;
26058 enemy_removal_point[spriteremovalX1] = -32767;
26059 enemy_removal_point[spriteremovalX2] = 32767;
26060 enemy_removal_point[spriteremovalZ1] = -32767;
26061 enemy_removal_point[spriteremovalZ2] = 32767;
26062
26063 for ( int32_t q = 0; q < 4; q++ )
26064 {
26065 FF_screenbounds[q] = 0;
26066 FF_screen_dimensions[q] = 0;
26067 FF_subscreen_dimensions[q] = 0;
26068 FF_eweapon_removal_bounds[q] = 0;
26069 FF_lweapon_removal_bounds[q] = 0;
26070 }
26071 for ( int32_t q = 0; q < FFSCRIPTCLASS_CLOCKS; q++ )
26072 {
26073 FF_clocks[q] = 0;
26074 }
26075 for ( int32_t q = 0; q < SCRIPT_DRAWING_RULES; q++ )
26076 {
26077 ScriptDrawingRules[q] = 0;
26078 }
26079 for ( int32_t q = 0; q < NUM_USER_MIDI_OVERRIDES; q++ )
26080 {
26081 FF_UserMidis[q] = 0;
26082 }
26083 subscreen_scroll_speed = 0; //make a define for a default and read quest override! -Z
26084 kb_typing_mode = false;
26085 initIncludePaths();
26086 }
26087
26088 void FFScript::updateIncludePaths()
26089 {
26090 includePaths.clear();
26091 int32_t pos = 0; int32_t pathnumber = 0;
26092 for ( int32_t q = 0; includePathString[pos]; ++q )
26093 {
26094 int32_t dest = 0;
26095 char buf[2048] = {0};
26096 while(includePathString[pos] != ';' && includePathString[pos])
26097 {
26098 buf[dest] = includePathString[pos];
26099 ++pos;
26100 ++dest;
26101 }
26102 ++pos;
26103 string str(buf);
26104 includePaths.push_back(str);
26105 }
26106 }
26107
26108 void FFScript::initIncludePaths()
26109 {
26110 memset(includePathString,0,sizeof(includePathString));
26111 FILE* f = fopen("includepaths.txt", "r");
26112 if(f)
26113 {
26114 int32_t pos = 0;
26115 int32_t c;
26116 do
26117 {
26118 c = fgetc(f);
26119 if(c!=EOF)
26120 includePathString[pos++] = c;
26121 }
26122 while(c!=EOF && pos<MAX_INCLUDE_PATH_CHARS);
26123 if(pos<MAX_INCLUDE_PATH_CHARS)
26124 includePathString[pos] = '\0';
26125 includePathString[MAX_INCLUDE_PATH_CHARS-1] = '\0';
26126 fclose(f);
26127 }
26128 else strcpy(includePathString, "include/;headers/;scripts/;");
26129 al_trace("Full path string is: ");
26130 safe_al_trace(includePathString);
26131 al_trace("\n");
26132 updateIncludePaths();
26133
26134 for ( size_t q = 0; q < includePaths.size(); ++q )
26135 {
26136 al_trace("Include path %zu: ",q);
26137 safe_al_trace(includePaths.at(q).c_str());
26138 al_trace("\n");
26139 }
26140 }
26141
26142 int32_t FFScript::getQRBit(int32_t rule)
26143 {
26144 return ( get_qr(rule) ? 1 : 0 );
26145 }
26146
26147 int32_t FFScript::getTime(int32_t type)
26148 {
26149 //struct tm *tm_struct = localtime(time(NULL));
26150 struct tm * tm_struct;
26151 time_t rawtime;
26152 time (&rawtime);
26153 tm_struct = localtime (&rawtime);
26154
26155 switch(type)
26156 {
26157 case curyear:
26158 {
26159 int32_t year = tm_struct->tm_year + 1900; /* year */
26160 //year format starts at 1900, so we add it to the return
26161 return year;
26162
26163 }
26164 case curmonth:
26165 {
26166 int32_t month = tm_struct->tm_mon +1; /* month */
26167 //Months start at 0, but we want 1->12
26168 return month;
26169 }
26170 case curday_month:
26171 {
26172 int32_t day_month = tm_struct->tm_mday; /* day of the month */
26173 return day_month;
26174 }
26175 case curday_week:
26176 {
26177 int32_t day_week = tm_struct->tm_wday; /* day of the week */
26178 return day_week;
26179 }
26180 case curhour:
26181 {
26182 int32_t hour = tm_struct->tm_hour; /* hours */
26183 return hour;
26184 }
26185 case curminute:
26186 {
26187 int32_t minutes = tm_struct->tm_min; /* minutes */
26188 return minutes;
26189 }
26190 case cursecond:
26191 {
26192 int32_t secs = tm_struct->tm_sec; /* seconds */
26193 return secs;
26194 }
26195 case curdayyear:
26196 {
26197 int32_t day_year = tm_struct->tm_yday; /* day in the year */
26198 return day_year;
26199 }
26200 case curDST:
26201 {
26202 int32_t isDST = tm_struct->tm_isdst; /* daylight saving time */
26203 return isDST;
26204 }
26205 default: return -1;
26206
26207 }
26208 }
26209
26210 extern const char *itemclass_help_string_defaults[itype_max];
26211
26212 /* end */
26213
26214 24576 int32_t FFScript::getQuestHeaderInfo(int32_t type)
26215 {
26216 24576 return quest_format[type];
26217 }
26218
26219 bool isSideViewGravity(int32_t t)
26220 {
26221 return (Map.CurrScr()->flags7&fSIDEVIEW) != 0;
26222 }
26223
26224
26225
26226
26227 void FFScript::ZScriptConsole(bool open)
26228 {
26229
26230
26231 #ifdef _WIN32
26232 if ( console_is_open )
26233 {
26234 zscript_coloured_console.Create("ZQuest Classic Logging Console", 600, 200);
26235 zscript_coloured_console.cls(CConsoleLoggerEx::COLOR_BACKGROUND_BLACK);
26236 zscript_coloured_console.gotoxy(0,0);
26237 zscript_coloured_console.cprintf( CConsoleLoggerEx::COLOR_BLUE | CConsoleLoggerEx::COLOR_INTENSITY |
26238 CConsoleLoggerEx::COLOR_BACKGROUND_BLACK,"ZQuest Classic Logging Console\n");
26239 }
26240 else
26241 {
26242 //close
26243 zscript_coloured_console.Close();
26244 }
26245 #endif
26246 }
26247
26248 template <typename ...Params>
26249 void FFScript::ZScriptConsole(int32_t attributes,const char *format, Params&&... params)
26250 {
26251 #ifdef _WIN32
26252 initConsole();
26253 zscript_coloured_console.cprintf( attributes, format, std::forward<Params>(params)... );
26254 #endif
26255 }
26256
26257 int32_t getpitfall(int32_t x, int32_t y){return 0;}
26258
26259 bool update_hw_pal = false;
26260 void update_hw_screen()
26261 {
26262 if (is_headless())
26263 return;
26264
26265 framecnt++;
26266
26267 zc_process_display_events();
26268 if (update_hw_pal)
26269 {
26270 zc_set_palette(RAMpal);
26271 update_hw_pal = false;
26272 }
26273
26274 render_timer_wait();
26275 render_zq();
26276 }
26277
26278 bool checkCost(int32_t ctr, int32_t amnt)
26279 {
26280 if(!game) return true;
26281 if(amnt <= 0) return true;
26282 switch (ctr)
26283 {
26284 case crMONEY: //rupees
26285 {
26286 if ( current_item_power(itype_wallet) ) return true;
26287 break;
26288 }
26289 case crMAGIC: //magic
26290 {
26291 if (get_qr(qr_ENABLEMAGIC))
26292 {
26293 return (((current_item_power(itype_magicring) > 0)
26294 ? game->get_maxmagic()
26295 : game->get_magic()+game->get_dmagic())>=amnt*game->get_magicdrainrate());
26296 }
26297 return true;
26298 }
26299 case crARROWS:
26300 {
26301 if(current_item_power(itype_quiver))
26302 return true;
26303 if(!get_qr(qr_TRUEARROWS))
26304 return checkCost(crMONEY, amnt);
26305 break;
26306 }
26307 case crBOMBS:
26308 {
26309 if(current_item_power(itype_bombbag))
26310 return true;
26311 break;
26312 }
26313 case crSBOMBS:
26314 {
26315 if(current_item_power(itype_bombbag)
26316 && itemsbuf[current_item_id(itype_bombbag)].flags & item_flag1)
26317 return true;
26318 break;
26319 }
26320 }
26321 return (game->get_counter(ctr)+game->get_dcounter(ctr)>=amnt);
26322 }
26323 bool checkmagiccost(int32_t itemid, bool checkTime)
26324 {
26325 if(itemid < 0)
26326 {
26327 return false;
26328 }
26329 itemdata const& id = itemsbuf[itemid];
26330 return checkCost(id.cost_counter[0], id.cost_amount[0])
26331 && checkCost(id.cost_counter[1], id.cost_amount[1]);
26332 }
26333
26334 void payCost(int32_t ctr, int32_t amnt, int32_t tmr, bool ignoreTimer)
26335 {
26336 return;
26337 }
26338 void paymagiccost(int32_t itemid, bool ignoreTimer, bool onlyTimer)
26339 {
26340 return;
26341 }
26342 bool is_in_scrolling_region()
26343 {
26344 return false;
26345 }
26346
26347 void enter_sys_pal(){}
26348 void exit_sys_pal(){}
26349
26350 void replay_step_comment(std::string comment) {}
26351 bool replay_is_active() {return false;}
26352 9 bool replay_is_replaying() {return false;}
26353 bool replay_version_check(int min, int max) {return false;}
26354 bool replay_is_debug() {return false;}
26355 std::string replay_get_meta_str(std::string key){return "";}
26356 int32_t item::run_script(int32_t mode){return 0;};
26357 ffcdata* slopes_getFFC(int id)
26358 {
26359 return nullptr;
26360 }
26361
26362 #ifdef __EMSCRIPTEN__
26363 extern "C" void open_test_mode()
26364 {
26365 int dmap = -1;
26366 int32_t pal = Map.getcolor();
26367 for(auto q = 0; q < MAXDMAPS; ++q)
26368 {
26369 if(DMaps[q].map == Map.getCurrMap())
26370 {
26371 if(pal == DMaps[q].color)
26372 {
26373 dmap = q;
26374 break;
26375 }
26376 if(dmap < 0)
26377 dmap = q;
26378 }
26379 }
26380 if(dmap < 0) dmap = 0;
26381
26382 em_open_test_mode(filepath, dmap, Map.getCurrScr(), -1);
26383 }
26384
26385 extern "C" void get_shareable_url()
26386 {
26387 EM_ASM({
26388 ZC.setShareableUrl({open: UTF8ToString($0), map: $1, screen: $2});
26389 }, filepath, Map.getCurrMap(), Map.getCurrScr());
26390 }
26391 #endif
26392
26393 11 void setZScriptVersion(int32_t v){}
26394